1
|
|
|
import React, { Fragment, useEffect, useState, useContext } 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 moment from 'moment'; |
20
|
|
|
import loadable from '@loadable/component'; |
21
|
|
|
import Cascader from 'rc-cascader'; |
22
|
|
|
import CardSummary from '../common/CardSummary'; |
23
|
|
|
import MultiTrendChart from '../common/MultiTrendChart'; |
24
|
|
|
import SharePie from '../common/SharePie'; |
25
|
|
|
import { getCookieValue, createCookie } from '../../../helpers/utils'; |
26
|
|
|
import withRedirect from '../../../hoc/withRedirect'; |
27
|
|
|
import { withTranslation } from 'react-i18next'; |
28
|
|
|
import { toast } from 'react-toastify'; |
29
|
|
|
import ButtonIcon from '../../common/ButtonIcon'; |
30
|
|
|
import { APIBaseURL } from '../../../config'; |
31
|
|
|
import { periodTypeOptions } from '../common/PeriodTypeOptions'; |
32
|
|
|
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions'; |
33
|
|
|
import DateRangePickerWrapper from '../common/DateRangePickerWrapper'; |
34
|
|
|
import { endOfDay} from 'date-fns'; |
35
|
|
|
import AppContext from '../../../context/Context'; |
36
|
|
|
import MultipleLineChart from '../common/MultipleLineChart'; |
37
|
|
|
|
38
|
|
|
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable')); |
39
|
|
|
|
40
|
|
|
const ShopfloorSaving = ({ setRedirect, setRedirectUrl, t }) => { |
41
|
|
|
let current_moment = moment(); |
42
|
|
|
useEffect(() => { |
43
|
|
|
let is_logged_in = getCookieValue('is_logged_in'); |
44
|
|
|
let user_name = getCookieValue('user_name'); |
45
|
|
|
let user_display_name = getCookieValue('user_display_name'); |
46
|
|
|
let user_uuid = getCookieValue('user_uuid'); |
47
|
|
|
let token = getCookieValue('token'); |
48
|
|
|
if (is_logged_in === null || !is_logged_in) { |
49
|
|
|
setRedirectUrl(`/authentication/basic/login`); |
50
|
|
|
setRedirect(true); |
51
|
|
|
} else { |
52
|
|
|
//update expires time of cookies |
53
|
|
|
createCookie('is_logged_in', true, 1000 * 60 * 60 * 8); |
54
|
|
|
createCookie('user_name', user_name, 1000 * 60 * 60 * 8); |
55
|
|
|
createCookie('user_display_name', user_display_name, 1000 * 60 * 60 * 8); |
56
|
|
|
createCookie('user_uuid', user_uuid, 1000 * 60 * 60 * 8); |
57
|
|
|
createCookie('token', token, 1000 * 60 * 60 * 8); |
58
|
|
|
} |
59
|
|
|
}); |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
// State |
63
|
|
|
// Query Parameters |
64
|
|
|
const [selectedSpaceName, setSelectedSpaceName] = useState(undefined); |
65
|
|
|
const [selectedSpaceID, setSelectedSpaceID] = useState(undefined); |
66
|
|
|
const [shopfloorList, setShopfloorList] = useState([]); |
67
|
|
|
const [selectedShopfloor, setSelectedShopfloor] = useState(undefined); |
68
|
|
|
const [comparisonType, setComparisonType] = useState('month-on-month'); |
69
|
|
|
const [periodType, setPeriodType] = useState('daily'); |
70
|
|
|
const [cascaderOptions, setCascaderOptions] = useState(undefined); |
71
|
|
|
const [basePeriodDateRange, setBasePeriodDateRange] = useState([current_moment.clone().subtract(1, 'months').startOf('month').toDate(), current_moment.clone().subtract(1, 'months').toDate()]); |
72
|
|
|
const [basePeriodDateRangePickerDisabled, setBasePeriodDateRangePickerDisabled] = useState(true); |
73
|
|
|
const [reportingPeriodDateRange, setReportingPeriodDateRange] = useState([current_moment.clone().startOf('month').toDate(), current_moment.toDate()]); |
74
|
|
|
const dateRangePickerLocale = { |
75
|
|
|
sunday: t('sunday'), |
76
|
|
|
monday: t('monday'), |
77
|
|
|
tuesday: t('tuesday'), |
78
|
|
|
wednesday: t('wednesday'), |
79
|
|
|
thursday: t('thursday'), |
80
|
|
|
friday: t('friday'), |
81
|
|
|
saturday: t('saturday'), |
82
|
|
|
ok: t('ok'), |
83
|
|
|
today: t('today'), |
84
|
|
|
yesterday: t('yesterday'), |
85
|
|
|
hours: t('hours'), |
86
|
|
|
minutes: t('minutes'), |
87
|
|
|
seconds: t('seconds'), |
88
|
|
|
last7Days: t('last7Days'), |
89
|
|
|
formattedMonthPattern: 'yyyy-MM-dd' |
90
|
|
|
}; |
91
|
|
|
const dateRangePickerStyle = { display: 'block', zIndex: 10}; |
92
|
|
|
const { language } = useContext(AppContext); |
93
|
|
|
|
94
|
|
|
// buttons |
95
|
|
|
const [submitButtonDisabled, setSubmitButtonDisabled] = useState(true); |
96
|
|
|
const [spinnerHidden, setSpinnerHidden] = useState(true); |
97
|
|
|
const [exportButtonHidden, setExportButtonHidden] = useState(true); |
98
|
|
|
|
99
|
|
|
//Results |
100
|
|
|
const [TCEShareData, setTCEShareData] = useState([]); |
101
|
|
|
const [TCO2EShareData, setTCO2EShareData] = useState([]); |
102
|
|
|
|
103
|
|
|
const [cardSummaryList, setCardSummaryList] = useState([]); |
104
|
|
|
const [totalInTCE, setTotalInTCE] = useState({}); |
105
|
|
|
const [totalInTCO2E, setTotalInTCO2E] = useState({}); |
106
|
|
|
|
107
|
|
|
const [shopfloorBaseAndReportingNames, setShopfloorBaseAndReportingNames] = useState({"a0":""}); |
108
|
|
|
const [shopfloorBaseAndReportingUnits, setShopfloorBaseAndReportingUnits] = useState({"a0":"()"}); |
109
|
|
|
|
110
|
|
|
const [shopfloorBaseLabels, setShopfloorBaseLabels] = useState({"a0": []}); |
111
|
|
|
const [shopfloorBaseData, setShopfloorBaseData] = useState({"a0": []}); |
112
|
|
|
const [shopfloorBaseSubtotals, setShopfloorBaseSubtotals] = useState({"a0": (0).toFixed(2)}); |
113
|
|
|
|
114
|
|
|
const [shopfloorReportingLabels, setShopfloorReportingLabels] = useState({"a0": []}); |
115
|
|
|
const [shopfloorReportingData, setShopfloorReportingData] = useState({"a0": []}); |
116
|
|
|
const [shopfloorReportingSubtotals, setShopfloorReportingSubtotals] = useState({"a0": (0).toFixed(2)}); |
117
|
|
|
|
118
|
|
|
const [shopfloorReportingRates, setShopfloorReportingRates] = useState({"a0": []}); |
119
|
|
|
const [shopfloorReportingOptions, setShopfloorReportingOptions] = useState([]); |
120
|
|
|
|
121
|
|
|
const [parameterLineChartLabels, setParameterLineChartLabels] = useState([]); |
122
|
|
|
const [parameterLineChartData, setParameterLineChartData] = useState({}); |
123
|
|
|
const [parameterLineChartOptions, setParameterLineChartOptions] = useState([]); |
124
|
|
|
|
125
|
|
|
const [detailedDataTableData, setDetailedDataTableData] = useState([]); |
126
|
|
|
const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]); |
127
|
|
|
const [excelBytesBase64, setExcelBytesBase64] = useState(undefined); |
128
|
|
|
|
129
|
|
|
useEffect(() => { |
130
|
|
|
let isResponseOK = false; |
131
|
|
|
fetch(APIBaseURL + '/spaces/tree', { |
132
|
|
|
method: 'GET', |
133
|
|
|
headers: { |
134
|
|
|
"Content-type": "application/json", |
135
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
136
|
|
|
"Token": getCookieValue('token') |
137
|
|
|
}, |
138
|
|
|
body: null, |
139
|
|
|
|
140
|
|
|
}).then(response => { |
141
|
|
|
console.log(response); |
142
|
|
|
if (response.ok) { |
143
|
|
|
isResponseOK = true; |
144
|
|
|
} |
145
|
|
|
return response.json(); |
146
|
|
|
}).then(json => { |
147
|
|
|
console.log(json); |
148
|
|
|
if (isResponseOK) { |
149
|
|
|
// rename keys |
150
|
|
|
json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":')); |
151
|
|
|
setCascaderOptions(json); |
152
|
|
|
setSelectedSpaceName([json[0]].map(o => o.label)); |
153
|
|
|
setSelectedSpaceID([json[0]].map(o => o.value)); |
154
|
|
|
// get Shopfloors by root Space ID |
155
|
|
|
let isResponseOK = false; |
156
|
|
|
fetch(APIBaseURL + '/spaces/' + [json[0]].map(o => o.value) + '/shopfloors', { |
157
|
|
|
method: 'GET', |
158
|
|
|
headers: { |
159
|
|
|
"Content-type": "application/json", |
160
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
161
|
|
|
"Token": getCookieValue('token') |
162
|
|
|
}, |
163
|
|
|
body: null, |
164
|
|
|
|
165
|
|
|
}).then(response => { |
166
|
|
|
if (response.ok) { |
167
|
|
|
isResponseOK = true; |
168
|
|
|
} |
169
|
|
|
return response.json(); |
170
|
|
|
}).then(json => { |
171
|
|
|
if (isResponseOK) { |
172
|
|
|
json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":')); |
173
|
|
|
console.log(json); |
174
|
|
|
setShopfloorList(json[0]); |
175
|
|
|
if (json[0].length > 0) { |
176
|
|
|
setSelectedShopfloor(json[0][0].value); |
177
|
|
|
// enable submit button |
178
|
|
|
setSubmitButtonDisabled(false); |
179
|
|
|
} else { |
180
|
|
|
setSelectedShopfloor(undefined); |
181
|
|
|
// disable submit button |
182
|
|
|
setSubmitButtonDisabled(true); |
183
|
|
|
} |
184
|
|
|
} else { |
185
|
|
|
toast.error(t(json.description)) |
186
|
|
|
} |
187
|
|
|
}).catch(err => { |
188
|
|
|
console.log(err); |
189
|
|
|
}); |
190
|
|
|
// end of get Shopfloors by root Space ID |
191
|
|
|
} else { |
192
|
|
|
toast.error(t(json.description)); |
193
|
|
|
} |
194
|
|
|
}).catch(err => { |
195
|
|
|
console.log(err); |
196
|
|
|
}); |
197
|
|
|
|
198
|
|
|
}, []); |
199
|
|
|
|
200
|
|
|
const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0'; |
201
|
|
|
|
202
|
|
|
let onSpaceCascaderChange = (value, selectedOptions) => { |
203
|
|
|
setSelectedSpaceName(selectedOptions.map(o => o.label).join('/')); |
204
|
|
|
setSelectedSpaceID(value[value.length - 1]); |
205
|
|
|
|
206
|
|
|
let isResponseOK = false; |
207
|
|
|
fetch(APIBaseURL + '/spaces/' + value[value.length - 1] + '/shopfloors', { |
208
|
|
|
method: 'GET', |
209
|
|
|
headers: { |
210
|
|
|
"Content-type": "application/json", |
211
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
212
|
|
|
"Token": getCookieValue('token') |
213
|
|
|
}, |
214
|
|
|
body: null, |
215
|
|
|
|
216
|
|
|
}).then(response => { |
217
|
|
|
if (response.ok) { |
218
|
|
|
isResponseOK = true; |
219
|
|
|
} |
220
|
|
|
return response.json(); |
221
|
|
|
}).then(json => { |
222
|
|
|
if (isResponseOK) { |
223
|
|
|
json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":')); |
224
|
|
|
console.log(json) |
225
|
|
|
setShopfloorList(json[0]); |
226
|
|
|
if (json[0].length > 0) { |
227
|
|
|
setSelectedShopfloor(json[0][0].value); |
228
|
|
|
// enable submit button |
229
|
|
|
setSubmitButtonDisabled(false); |
230
|
|
|
} else { |
231
|
|
|
setSelectedShopfloor(undefined); |
232
|
|
|
// disable submit button |
233
|
|
|
setSubmitButtonDisabled(true); |
234
|
|
|
} |
235
|
|
|
} else { |
236
|
|
|
toast.error(t(json.description)) |
237
|
|
|
} |
238
|
|
|
}).catch(err => { |
239
|
|
|
console.log(err); |
240
|
|
|
}); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
|
244
|
|
|
let onComparisonTypeChange = ({ target }) => { |
245
|
|
|
console.log(target.value); |
246
|
|
|
setComparisonType(target.value); |
247
|
|
|
if (target.value === 'year-over-year') { |
248
|
|
|
setBasePeriodDateRangePickerDisabled(true); |
249
|
|
|
setBasePeriodDateRange([moment(reportingPeriodDateRange[0]).subtract(1, 'years').toDate(), |
250
|
|
|
moment(reportingPeriodDateRange[1]).subtract(1, 'years').toDate()]); |
251
|
|
|
} else if (target.value === 'month-on-month') { |
252
|
|
|
setBasePeriodDateRangePickerDisabled(true); |
253
|
|
|
setBasePeriodDateRange([moment(reportingPeriodDateRange[0]).subtract(1, 'months').toDate(), |
254
|
|
|
moment(reportingPeriodDateRange[1]).subtract(1, 'months').toDate()]); |
255
|
|
|
} else if (target.value === 'free-comparison') { |
256
|
|
|
setBasePeriodDateRangePickerDisabled(false); |
257
|
|
|
} else if (target.value === 'none-comparison') { |
258
|
|
|
setBasePeriodDateRange([null, null]); |
259
|
|
|
setBasePeriodDateRangePickerDisabled(true); |
260
|
|
|
} |
261
|
|
|
}; |
262
|
|
|
|
263
|
|
|
// Callback fired when value changed |
264
|
|
|
let onBasePeriodChange = (DateRange) => { |
265
|
|
|
if(DateRange == null) { |
266
|
|
|
setBasePeriodDateRange([null, null]); |
267
|
|
|
} else { |
268
|
|
|
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') { |
269
|
|
|
// if the user did not change time value, set the default time to the end of day |
270
|
|
|
DateRange[1] = endOfDay(DateRange[1]); |
271
|
|
|
} |
272
|
|
|
setBasePeriodDateRange([DateRange[0], DateRange[1]]); |
273
|
|
|
} |
274
|
|
|
}; |
275
|
|
|
|
276
|
|
|
// Callback fired when value changed |
277
|
|
|
let onReportingPeriodChange = (DateRange) => { |
278
|
|
|
if(DateRange == null) { |
279
|
|
|
setReportingPeriodDateRange([null, null]); |
280
|
|
|
} else { |
281
|
|
|
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') { |
282
|
|
|
// if the user did not change time value, set the default time to the end of day |
283
|
|
|
DateRange[1] = endOfDay(DateRange[1]); |
284
|
|
|
} |
285
|
|
|
setReportingPeriodDateRange([DateRange[0], DateRange[1]]); |
286
|
|
|
if (comparisonType === 'year-over-year') { |
287
|
|
|
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]); |
288
|
|
|
} else if (comparisonType === 'month-on-month') { |
289
|
|
|
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'months').toDate(), moment(DateRange[1]).clone().subtract(1, 'months').toDate()]); |
290
|
|
|
} |
291
|
|
|
} |
292
|
|
|
}; |
293
|
|
|
|
294
|
|
|
// Callback fired when value clean |
295
|
|
|
let onBasePeriodClean = event => { |
296
|
|
|
setBasePeriodDateRange([null, null]); |
297
|
|
|
}; |
298
|
|
|
|
299
|
|
|
// Callback fired when value clean |
300
|
|
|
let onReportingPeriodClean = event => { |
301
|
|
|
setReportingPeriodDateRange([null, null]); |
302
|
|
|
}; |
303
|
|
|
|
304
|
|
|
const isBasePeriodTimestampExists = (base_period_data) => { |
305
|
|
|
const timestamps = base_period_data['timestamps']; |
306
|
|
|
|
307
|
|
|
if (timestamps.length === 0) { |
308
|
|
|
return false; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
for (let i = 0; i < timestamps.length; i++) { |
312
|
|
|
if (timestamps[i].length > 0) { |
313
|
|
|
return true; |
314
|
|
|
} |
315
|
|
|
} |
316
|
|
|
return false |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
// Handler |
320
|
|
|
const handleSubmit = e => { |
321
|
|
|
e.preventDefault(); |
322
|
|
|
console.log('handleSubmit'); |
323
|
|
|
console.log(selectedSpaceID); |
324
|
|
|
console.log(selectedShopfloor); |
325
|
|
|
console.log(comparisonType); |
326
|
|
|
console.log(periodType); |
327
|
|
|
console.log(basePeriodDateRange[0] != null ? moment(basePeriodDateRange[0]).format('YYYY-MM-DDTHH:mm:ss') : null) |
328
|
|
|
console.log(basePeriodDateRange[1] != null ? moment(basePeriodDateRange[1]).format('YYYY-MM-DDTHH:mm:ss') : null) |
329
|
|
|
console.log(moment(reportingPeriodDateRange[0]).format('YYYY-MM-DDTHH:mm:ss')) |
330
|
|
|
console.log(moment(reportingPeriodDateRange[1]).format('YYYY-MM-DDTHH:mm:ss')); |
331
|
|
|
|
332
|
|
|
// disable submit button |
333
|
|
|
setSubmitButtonDisabled(true); |
334
|
|
|
// show spinner |
335
|
|
|
setSpinnerHidden(false); |
336
|
|
|
// hide export button |
337
|
|
|
setExportButtonHidden(true) |
338
|
|
|
|
339
|
|
|
// Reinitialize tables |
340
|
|
|
setDetailedDataTableData([]); |
341
|
|
|
|
342
|
|
|
let isResponseOK = false; |
343
|
|
|
fetch(APIBaseURL + '/reports/shopfloorsaving?' + |
344
|
|
|
'shopfloorid=' + selectedShopfloor + |
345
|
|
|
'&periodtype=' + periodType + |
346
|
|
|
'&baseperiodstartdatetime=' + (basePeriodDateRange[0] != null ? moment(basePeriodDateRange[0]).format('YYYY-MM-DDTHH:mm:ss') : '') + |
347
|
|
|
'&baseperiodenddatetime=' + (basePeriodDateRange[1] != null ? moment(basePeriodDateRange[1]).format('YYYY-MM-DDTHH:mm:ss') : '') + |
348
|
|
|
'&reportingperiodstartdatetime=' + moment(reportingPeriodDateRange[0]).format('YYYY-MM-DDTHH:mm:ss') + |
349
|
|
|
'&reportingperiodenddatetime=' + moment(reportingPeriodDateRange[1]).format('YYYY-MM-DDTHH:mm:ss') + |
350
|
|
|
'&language=' + language, { |
351
|
|
|
method: 'GET', |
352
|
|
|
headers: { |
353
|
|
|
"Content-type": "application/json", |
354
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
355
|
|
|
"Token": getCookieValue('token') |
356
|
|
|
}, |
357
|
|
|
body: null, |
358
|
|
|
|
359
|
|
|
}).then(response => { |
360
|
|
|
if (response.ok) { |
361
|
|
|
isResponseOK = true; |
362
|
|
|
}; |
363
|
|
|
return response.json(); |
364
|
|
|
}).then(json => { |
365
|
|
|
if (isResponseOK) { |
366
|
|
|
console.log(json); |
367
|
|
|
|
368
|
|
|
let cardSummaryArray = [] |
369
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
370
|
|
|
let cardSummaryItem = {} |
371
|
|
|
cardSummaryItem['name'] = json['reporting_period']['names'][index]; |
372
|
|
|
cardSummaryItem['unit'] = json['reporting_period']['units'][index]; |
373
|
|
|
cardSummaryItem['subtotal'] = json['reporting_period']['subtotals_saving'][index]; |
374
|
|
|
cardSummaryItem['increment_rate'] = parseFloat(json['reporting_period']['increment_rates_saving'][index] * 100).toFixed(2) + "%"; |
375
|
|
|
cardSummaryItem['subtotal_per_unit_area'] = json['reporting_period']['subtotals_per_unit_area_saving'][index]; |
376
|
|
|
cardSummaryArray.push(cardSummaryItem); |
377
|
|
|
}); |
378
|
|
|
setCardSummaryList(cardSummaryArray); |
379
|
|
|
|
380
|
|
|
let totalInTCE = {}; |
381
|
|
|
totalInTCE['value'] = json['reporting_period']['total_in_kgce_saving'] / 1000; // convert from kg to t |
382
|
|
|
totalInTCE['increment_rate'] = parseFloat(json['reporting_period']['increment_rate_in_kgce_saving'] * 100).toFixed(2) + "%"; |
383
|
|
|
totalInTCE['value_per_unit_area'] = json['reporting_period']['total_in_kgce_per_unit_area_saving'] / 1000; // convert from kg to t |
384
|
|
|
setTotalInTCE(totalInTCE); |
385
|
|
|
|
386
|
|
|
let totalInTCO2E = {}; |
387
|
|
|
totalInTCO2E['value'] = json['reporting_period']['total_in_kgco2e_saving'] / 1000; // convert from kg to t |
388
|
|
|
totalInTCO2E['increment_rate'] = parseFloat(json['reporting_period']['increment_rate_in_kgco2e_saving'] * 100).toFixed(2) + "%"; |
389
|
|
|
totalInTCO2E['value_per_unit_area'] = json['reporting_period']['total_in_kgco2e_per_unit_area_saving'] / 1000; // convert from kg to t |
390
|
|
|
setTotalInTCO2E(totalInTCO2E); |
391
|
|
|
|
392
|
|
|
let TCEDataArray = []; |
393
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
394
|
|
|
let TCEDataItem = {} |
395
|
|
|
TCEDataItem['id'] = index; |
396
|
|
|
TCEDataItem['name'] = currentValue; |
397
|
|
|
TCEDataItem['value'] = json['reporting_period']['subtotals_in_kgce_saving'][index] / 1000; // convert from kg to t |
398
|
|
|
TCEDataItem['color'] = "#"+((1<<24)*Math.random()|0).toString(16); |
399
|
|
|
TCEDataArray.push(TCEDataItem); |
400
|
|
|
}); |
401
|
|
|
setTCEShareData(TCEDataArray); |
402
|
|
|
|
403
|
|
|
let TCO2EDataArray = []; |
404
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
405
|
|
|
let TCO2EDataItem = {} |
406
|
|
|
TCO2EDataItem['id'] = index; |
407
|
|
|
TCO2EDataItem['name'] = currentValue; |
408
|
|
|
TCO2EDataItem['value'] = json['reporting_period']['subtotals_in_kgco2e_saving'][index] / 1000; // convert from kg to t |
409
|
|
|
TCO2EDataItem['color'] = "#"+((1<<24)*Math.random()|0).toString(16); |
410
|
|
|
TCO2EDataArray.push(TCO2EDataItem); |
411
|
|
|
}); |
412
|
|
|
setTCO2EShareData(TCO2EDataArray); |
413
|
|
|
|
414
|
|
|
let base_timestamps = {} |
415
|
|
|
json['base_period']['timestamps'].forEach((currentValue, index) => { |
416
|
|
|
base_timestamps['a' + index] = currentValue; |
417
|
|
|
}); |
418
|
|
|
setShopfloorBaseLabels(base_timestamps) |
419
|
|
|
|
420
|
|
|
let base_values = {} |
421
|
|
|
json['base_period']['values_saving'].forEach((currentValue, index) => { |
422
|
|
|
base_values['a' + index] = currentValue; |
423
|
|
|
}); |
424
|
|
|
setShopfloorBaseData(base_values) |
425
|
|
|
|
426
|
|
|
/* |
427
|
|
|
* Tip: |
428
|
|
|
* base_names === reporting_names |
429
|
|
|
* base_units === reporting_units |
430
|
|
|
* */ |
431
|
|
|
|
432
|
|
|
let base_and_reporting_names = {} |
433
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
434
|
|
|
base_and_reporting_names['a' + index] = currentValue; |
435
|
|
|
}); |
436
|
|
|
setShopfloorBaseAndReportingNames(base_and_reporting_names) |
437
|
|
|
|
438
|
|
|
let base_and_reporting_units = {} |
439
|
|
|
json['reporting_period']['units'].forEach((currentValue, index) => { |
440
|
|
|
base_and_reporting_units['a' + index] = "("+currentValue+")"; |
441
|
|
|
}); |
442
|
|
|
setShopfloorBaseAndReportingUnits(base_and_reporting_units) |
443
|
|
|
|
444
|
|
|
let base_subtotals = {} |
445
|
|
|
json['base_period']['subtotals_saving'].forEach((currentValue, index) => { |
446
|
|
|
base_subtotals['a' + index] = currentValue.toFixed(2); |
447
|
|
|
}); |
448
|
|
|
setShopfloorBaseSubtotals(base_subtotals) |
449
|
|
|
|
450
|
|
|
let reporting_timestamps = {} |
451
|
|
|
json['reporting_period']['timestamps'].forEach((currentValue, index) => { |
452
|
|
|
reporting_timestamps['a' + index] = currentValue; |
453
|
|
|
}); |
454
|
|
|
setShopfloorReportingLabels(reporting_timestamps); |
455
|
|
|
|
456
|
|
|
let reporting_values = {} |
457
|
|
|
json['reporting_period']['values_saving'].forEach((currentValue, index) => { |
458
|
|
|
reporting_values['a' + index] = currentValue; |
459
|
|
|
}); |
460
|
|
|
setShopfloorReportingData(reporting_values); |
461
|
|
|
|
462
|
|
|
let reporting_subtotals = {} |
463
|
|
|
json['reporting_period']['subtotals_saving'].forEach((currentValue, index) => { |
464
|
|
|
reporting_subtotals['a' + index] = currentValue.toFixed(2); |
465
|
|
|
}); |
466
|
|
|
setShopfloorReportingSubtotals(reporting_subtotals); |
467
|
|
|
|
468
|
|
|
let rates = {} |
469
|
|
|
json['reporting_period']['rates_saving'].forEach((currentValue, index) => { |
470
|
|
|
let currentRate = Array(); |
471
|
|
|
currentValue.forEach((rate) => { |
472
|
|
|
currentRate.push(rate ? parseFloat(rate * 100).toFixed(2) : '0.00'); |
473
|
|
|
}); |
474
|
|
|
rates['a' + index] = currentRate; |
475
|
|
|
}); |
476
|
|
|
setShopfloorReportingRates(rates) |
477
|
|
|
|
478
|
|
|
let options = Array(); |
479
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
480
|
|
|
let unit = json['reporting_period']['units'][index]; |
481
|
|
|
options.push({ 'value': 'a' + index, 'label': currentValue + ' (' + unit + ')'}); |
482
|
|
|
}); |
483
|
|
|
setShopfloorReportingOptions(options); |
484
|
|
|
|
485
|
|
|
let timestamps = {} |
486
|
|
|
json['parameters']['timestamps'].forEach((currentValue, index) => { |
487
|
|
|
timestamps['a' + index] = currentValue; |
488
|
|
|
}); |
489
|
|
|
setParameterLineChartLabels(timestamps); |
490
|
|
|
|
491
|
|
|
let values = {} |
492
|
|
|
json['parameters']['values'].forEach((currentValue, index) => { |
493
|
|
|
values['a' + index] = currentValue; |
494
|
|
|
}); |
495
|
|
|
setParameterLineChartData(values); |
496
|
|
|
|
497
|
|
|
let names = Array(); |
498
|
|
|
json['parameters']['names'].forEach((currentValue, index) => { |
499
|
|
|
|
500
|
|
|
names.push({ 'value': 'a' + index, 'label': currentValue }); |
501
|
|
|
}); |
502
|
|
|
setParameterLineChartOptions(names); |
503
|
|
|
|
504
|
|
|
if(!isBasePeriodTimestampExists(json['base_period'])) { |
505
|
|
|
let detailed_value_list = []; |
506
|
|
|
if (json['reporting_period']['timestamps'].length > 0) { |
507
|
|
|
json['reporting_period']['timestamps'][0].forEach((currentTimestamp, timestampIndex) => { |
508
|
|
|
let detailed_value = {}; |
509
|
|
|
detailed_value['id'] = timestampIndex; |
510
|
|
|
detailed_value['startdatetime'] = currentTimestamp; |
511
|
|
|
json['reporting_period']['values_saving'].forEach((currentValue, energyCategoryIndex) => { |
512
|
|
|
detailed_value['a' + energyCategoryIndex] = json['reporting_period']['values_saving'][energyCategoryIndex][timestampIndex]; |
513
|
|
|
}); |
514
|
|
|
detailed_value_list.push(detailed_value); |
515
|
|
|
}); |
516
|
|
|
} |
517
|
|
|
; |
518
|
|
|
|
519
|
|
|
let detailed_value = {}; |
520
|
|
|
detailed_value['id'] = detailed_value_list.length; |
521
|
|
|
detailed_value['startdatetime'] = t('Subtotal'); |
522
|
|
|
json['reporting_period']['subtotals_saving'].forEach((currentValue, index) => { |
523
|
|
|
detailed_value['a' + index] = currentValue; |
524
|
|
|
}); |
525
|
|
|
detailed_value_list.push(detailed_value); |
526
|
|
|
setTimeout(() => { |
527
|
|
|
setDetailedDataTableData(detailed_value_list); |
528
|
|
|
}, 0) |
529
|
|
|
|
530
|
|
|
let detailed_column_list = []; |
531
|
|
|
detailed_column_list.push({ |
532
|
|
|
dataField: 'startdatetime', |
533
|
|
|
text: t('Datetime'), |
534
|
|
|
sort: true |
535
|
|
|
}); |
536
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
537
|
|
|
let unit = json['reporting_period']['units'][index]; |
538
|
|
|
detailed_column_list.push({ |
539
|
|
|
dataField: 'a' + index, |
540
|
|
|
text: currentValue + ' (' + unit + ')', |
541
|
|
|
sort: true, |
542
|
|
|
formatter: function (decimalValue) { |
543
|
|
|
if (typeof decimalValue === 'number') { |
544
|
|
|
return decimalValue.toFixed(2); |
545
|
|
|
} else { |
546
|
|
|
return null; |
547
|
|
|
} |
548
|
|
|
} |
549
|
|
|
}); |
550
|
|
|
}); |
551
|
|
|
setDetailedDataTableColumns(detailed_column_list); |
552
|
|
|
}else { |
553
|
|
|
/* |
554
|
|
|
* Tip: |
555
|
|
|
* json['base_period']['names'] === json['reporting_period']['names'] |
556
|
|
|
* json['base_period']['units'] === json['reporting_period']['units'] |
557
|
|
|
* */ |
558
|
|
|
let detailed_column_list = []; |
559
|
|
|
detailed_column_list.push({ |
560
|
|
|
dataField: 'basePeriodDatetime', |
561
|
|
|
text: t('Base Period') + ' - ' + t('Datetime'), |
562
|
|
|
sort: true |
563
|
|
|
}) |
564
|
|
|
|
565
|
|
|
json['base_period']['names'].forEach((currentValue, index) => { |
566
|
|
|
let unit = json['base_period']['units'][index]; |
567
|
|
|
detailed_column_list.push({ |
568
|
|
|
dataField: 'a' + index, |
569
|
|
|
text: t('Base Period') + ' - ' + currentValue + ' (' + unit + ')', |
570
|
|
|
sort: true, |
571
|
|
|
formatter: function (decimalValue) { |
572
|
|
|
if (typeof decimalValue === 'number') { |
573
|
|
|
return decimalValue.toFixed(2); |
574
|
|
|
} else { |
575
|
|
|
return null; |
576
|
|
|
} |
577
|
|
|
} |
578
|
|
|
}) |
579
|
|
|
}); |
580
|
|
|
|
581
|
|
|
detailed_column_list.push({ |
582
|
|
|
dataField: 'reportingPeriodDatetime', |
583
|
|
|
text: t('Reporting Period') + ' - ' + t('Datetime'), |
584
|
|
|
sort: true |
585
|
|
|
}) |
586
|
|
|
|
587
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
588
|
|
|
let unit = json['reporting_period']['units'][index]; |
589
|
|
|
detailed_column_list.push({ |
590
|
|
|
dataField: 'b' + index, |
591
|
|
|
text: t('Reporting Period') + ' - ' + currentValue + ' (' + unit + ')', |
592
|
|
|
sort: true, |
593
|
|
|
formatter: function (decimalValue) { |
594
|
|
|
if (typeof decimalValue === 'number') { |
595
|
|
|
return decimalValue.toFixed(2); |
596
|
|
|
} else { |
597
|
|
|
return null; |
598
|
|
|
} |
599
|
|
|
} |
600
|
|
|
}) |
601
|
|
|
}); |
602
|
|
|
setDetailedDataTableColumns(detailed_column_list); |
603
|
|
|
|
604
|
|
|
let detailed_value_list = []; |
605
|
|
|
if (json['base_period']['timestamps'].length > 0 || json['reporting_period']['timestamps'].length > 0) { |
606
|
|
|
const max_timestamps_length = json['base_period']['timestamps'][0].length >= json['reporting_period']['timestamps'][0].length? |
607
|
|
|
json['base_period']['timestamps'][0].length : json['reporting_period']['timestamps'][0].length; |
608
|
|
|
for (let index = 0; index < max_timestamps_length; index++) { |
609
|
|
|
let detailed_value = {}; |
610
|
|
|
detailed_value['id'] = index; |
611
|
|
|
detailed_value['basePeriodDatetime'] = index < json['base_period']['timestamps'][0].length? json['base_period']['timestamps'][0][index] : null; |
612
|
|
|
json['base_period']['values_saving'].forEach((currentValue, energyCategoryIndex) => { |
613
|
|
|
detailed_value['a' + energyCategoryIndex] = index < json['base_period']['values_saving'][energyCategoryIndex].length? json['base_period']['values_saving'][energyCategoryIndex][index] : null; |
614
|
|
|
}); |
615
|
|
|
detailed_value['reportingPeriodDatetime'] = index < json['reporting_period']['timestamps'][0].length? json['reporting_period']['timestamps'][0][index] : null; |
616
|
|
|
json['reporting_period']['values_saving'].forEach((currentValue, energyCategoryIndex) => { |
617
|
|
|
detailed_value['b' + energyCategoryIndex] = index < json['reporting_period']['values_saving'][energyCategoryIndex].length? json['reporting_period']['values_saving'][energyCategoryIndex][index] : null; |
618
|
|
|
}); |
619
|
|
|
detailed_value_list.push(detailed_value); |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
let detailed_value = {}; |
623
|
|
|
detailed_value['id'] = detailed_value_list.length; |
624
|
|
|
detailed_value['basePeriodDatetime'] = t('Subtotal'); |
625
|
|
|
json['base_period']['subtotals_saving'].forEach((currentValue, index) => { |
626
|
|
|
detailed_value['a' + index] = currentValue; |
627
|
|
|
}); |
628
|
|
|
detailed_value['reportingPeriodDatetime'] = t('Subtotal'); |
629
|
|
|
json['reporting_period']['subtotals_saving'].forEach((currentValue, index) => { |
630
|
|
|
detailed_value['b' + index] = currentValue; |
631
|
|
|
}); |
632
|
|
|
detailed_value_list.push(detailed_value); |
633
|
|
|
setTimeout( () => { |
634
|
|
|
setDetailedDataTableData(detailed_value_list); |
635
|
|
|
}, 0) |
636
|
|
|
} |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
setExcelBytesBase64(json['excel_bytes_base64']); |
640
|
|
|
|
641
|
|
|
// enable submit button |
642
|
|
|
setSubmitButtonDisabled(false); |
643
|
|
|
// hide spinner |
644
|
|
|
setSpinnerHidden(true); |
645
|
|
|
// show export button |
646
|
|
|
setExportButtonHidden(false); |
647
|
|
|
|
648
|
|
|
} else { |
649
|
|
|
toast.error(t(json.description)) |
650
|
|
|
} |
651
|
|
|
}).catch(err => { |
652
|
|
|
console.log(err); |
653
|
|
|
}); |
654
|
|
|
}; |
655
|
|
|
|
656
|
|
|
const handleExport = e => { |
657
|
|
|
e.preventDefault(); |
658
|
|
|
const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
659
|
|
|
const fileName = 'shopfloorsaving.xlsx' |
660
|
|
|
var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64; |
661
|
|
|
fetch(fileUrl) |
662
|
|
|
.then(response => response.blob()) |
663
|
|
|
.then(blob => { |
664
|
|
|
var link = window.document.createElement("a"); |
665
|
|
|
link.href = window.URL.createObjectURL(blob, { type: mimeType }); |
666
|
|
|
link.download = fileName; |
667
|
|
|
document.body.appendChild(link); |
668
|
|
|
link.click(); |
669
|
|
|
document.body.removeChild(link); |
670
|
|
|
}); |
671
|
|
|
}; |
672
|
|
|
|
673
|
|
|
|
674
|
|
|
return ( |
675
|
|
|
<Fragment> |
676
|
|
|
<div> |
677
|
|
|
<Breadcrumb> |
678
|
|
|
<BreadcrumbItem>{t('Shopfloor Data')}</BreadcrumbItem><BreadcrumbItem active>{t('Saving')}</BreadcrumbItem> |
679
|
|
|
</Breadcrumb> |
680
|
|
|
</div> |
681
|
|
|
<Card className="bg-light mb-3"> |
682
|
|
|
<CardBody className="p-3"> |
683
|
|
|
<Form onSubmit={handleSubmit}> |
684
|
|
|
<Row form> |
685
|
|
|
<Col xs={6} sm={3}> |
686
|
|
|
<FormGroup className="form-group"> |
687
|
|
|
<Label className={labelClasses} for="space"> |
688
|
|
|
{t('Space')} |
689
|
|
|
</Label> |
690
|
|
|
<br /> |
691
|
|
|
<Cascader options={cascaderOptions} |
692
|
|
|
onChange={onSpaceCascaderChange} |
693
|
|
|
changeOnSelect |
694
|
|
|
expandTrigger="hover"> |
695
|
|
|
<Input value={selectedSpaceName || ''} readOnly /> |
696
|
|
|
</Cascader> |
697
|
|
|
</FormGroup> |
698
|
|
|
</Col> |
699
|
|
|
<Col xs="auto"> |
700
|
|
|
<FormGroup> |
701
|
|
|
<Label className={labelClasses} for="shopfloorSelect"> |
702
|
|
|
{t('Shopfloor')} |
703
|
|
|
</Label> |
704
|
|
|
<CustomInput type="select" id="shopfloorSelect" name="shopfloorSelect" onChange={({ target }) => setSelectedShopfloor(target.value)} |
705
|
|
|
> |
706
|
|
|
{shopfloorList.map((shopfloor, index) => ( |
707
|
|
|
<option value={shopfloor.value} key={shopfloor.value}> |
708
|
|
|
{shopfloor.label} |
709
|
|
|
</option> |
710
|
|
|
))} |
711
|
|
|
</CustomInput> |
712
|
|
|
</FormGroup> |
713
|
|
|
</Col> |
714
|
|
|
<Col xs="auto"> |
715
|
|
|
<FormGroup> |
716
|
|
|
<Label className={labelClasses} for="comparisonType"> |
717
|
|
|
{t('Comparison Types')} |
718
|
|
|
</Label> |
719
|
|
|
<CustomInput type="select" id="comparisonType" name="comparisonType" |
720
|
|
|
defaultValue="month-on-month" |
721
|
|
|
onChange={onComparisonTypeChange} |
722
|
|
|
> |
723
|
|
|
{comparisonTypeOptions.map((comparisonType, index) => ( |
724
|
|
|
<option value={comparisonType.value} key={comparisonType.value} > |
725
|
|
|
{t(comparisonType.label)} |
726
|
|
|
</option> |
727
|
|
|
))} |
728
|
|
|
</CustomInput> |
729
|
|
|
</FormGroup> |
730
|
|
|
</Col> |
731
|
|
|
<Col xs="auto"> |
732
|
|
|
<FormGroup> |
733
|
|
|
<Label className={labelClasses} for="periodType"> |
734
|
|
|
{t('Period Types')} |
735
|
|
|
</Label> |
736
|
|
|
<CustomInput type="select" id="periodType" name="periodType" defaultValue="daily" onChange={({ target }) => setPeriodType(target.value)} |
737
|
|
|
> |
738
|
|
|
{periodTypeOptions.map((periodType, index) => ( |
739
|
|
|
<option value={periodType.value} key={periodType.value} > |
740
|
|
|
{t(periodType.label)} |
741
|
|
|
</option> |
742
|
|
|
))} |
743
|
|
|
</CustomInput> |
744
|
|
|
</FormGroup> |
745
|
|
|
</Col> |
746
|
|
|
<Col xs={6} sm={3}> |
747
|
|
|
<FormGroup className="form-group"> |
748
|
|
|
<Label className={labelClasses} for="basePeriodDateRangePicker">{t('Base Period')}{t('(Optional)')}</Label> |
749
|
|
|
<DateRangePickerWrapper |
750
|
|
|
id='basePeriodDateRangePicker' |
751
|
|
|
disabled={basePeriodDateRangePickerDisabled} |
752
|
|
|
format="yyyy-MM-dd HH:mm:ss" |
753
|
|
|
value={basePeriodDateRange} |
754
|
|
|
onChange={onBasePeriodChange} |
755
|
|
|
size="md" |
756
|
|
|
style={dateRangePickerStyle} |
757
|
|
|
onClean={onBasePeriodClean} |
758
|
|
|
locale={dateRangePickerLocale} |
759
|
|
|
placeholder={t("Select Date Range")} |
760
|
|
|
/> |
761
|
|
|
</FormGroup> |
762
|
|
|
</Col> |
763
|
|
|
<Col xs={6} sm={3}> |
764
|
|
|
<FormGroup className="form-group"> |
765
|
|
|
<Label className={labelClasses} for="reportingPeriodDateRangePicker">{t('Reporting Period')}</Label> |
766
|
|
|
<br/> |
767
|
|
|
<DateRangePickerWrapper |
768
|
|
|
id='reportingPeriodDateRangePicker' |
769
|
|
|
format="yyyy-MM-dd HH:mm:ss" |
770
|
|
|
value={reportingPeriodDateRange} |
771
|
|
|
onChange={onReportingPeriodChange} |
772
|
|
|
size="md" |
773
|
|
|
style={dateRangePickerStyle} |
774
|
|
|
onClean={onReportingPeriodClean} |
775
|
|
|
locale={dateRangePickerLocale} |
776
|
|
|
placeholder={t("Select Date Range")} |
777
|
|
|
/> |
778
|
|
|
</FormGroup> |
779
|
|
|
</Col> |
780
|
|
|
<Col xs="auto"> |
781
|
|
|
<FormGroup> |
782
|
|
|
<br></br> |
783
|
|
|
<ButtonGroup id="submit"> |
784
|
|
|
<Button color="success" disabled={submitButtonDisabled} >{t('Submit')}</Button> |
785
|
|
|
</ButtonGroup> |
786
|
|
|
</FormGroup> |
787
|
|
|
</Col> |
788
|
|
|
<Col xs="auto"> |
789
|
|
|
<FormGroup> |
790
|
|
|
<br></br> |
791
|
|
|
<Spinner color="primary" hidden={spinnerHidden} /> |
792
|
|
|
</FormGroup> |
793
|
|
|
</Col> |
794
|
|
|
<Col xs="auto"> |
795
|
|
|
<br></br> |
796
|
|
|
<ButtonIcon icon="external-link-alt" transform="shrink-3 down-2" color="falcon-default" |
797
|
|
|
hidden={exportButtonHidden} |
798
|
|
|
onClick={handleExport} > |
799
|
|
|
{t('Export')} |
800
|
|
|
</ButtonIcon> |
801
|
|
|
</Col> |
802
|
|
|
</Row> |
803
|
|
|
</Form> |
804
|
|
|
</CardBody> |
805
|
|
|
</Card> |
806
|
|
|
<div className="card-deck"> |
807
|
|
|
{cardSummaryList.map(cardSummaryItem => ( |
808
|
|
|
<CardSummary key={cardSummaryItem['name']} |
809
|
|
|
rate={cardSummaryItem['increment_rate']} |
810
|
|
|
title={t('Reporting Period Saving CATEGORY (Baseline - Actual) UNIT', { 'CATEGORY': cardSummaryItem['name'], 'UNIT': '(' + cardSummaryItem['unit'] + ')' })} |
811
|
|
|
color="success" |
812
|
|
|
footnote={t('Per Unit Area')} |
813
|
|
|
footvalue={cardSummaryItem['subtotal_per_unit_area']} |
814
|
|
|
footunit={"(" + cardSummaryItem['unit'] + "/M²)"} > |
815
|
|
|
{cardSummaryItem['subtotal'] && <CountUp end={cardSummaryItem['subtotal']} duration={2} prefix="" separator="," decimal="." decimals={2} />} |
816
|
|
|
</CardSummary> |
817
|
|
|
))} |
818
|
|
|
|
819
|
|
|
<CardSummary |
820
|
|
|
rate={totalInTCE['increment_rate'] || ''} |
821
|
|
|
title={t('Reporting Period Saving CATEGORY (Baseline - Actual) UNIT', { 'CATEGORY': t('Ton of Standard Coal'), 'UNIT': '(TCE)' })} |
822
|
|
|
color="warning" |
823
|
|
|
footnote={t('Per Unit Area')} |
824
|
|
|
footvalue={totalInTCE['value_per_unit_area']} |
825
|
|
|
footunit="(TCE/M²)"> |
826
|
|
|
{totalInTCE['value'] && <CountUp end={totalInTCE['value']} duration={2} prefix="" separator="," decimal="." decimals={2} />} |
827
|
|
|
</CardSummary> |
828
|
|
|
<CardSummary |
829
|
|
|
rate={totalInTCO2E['increment_rate'] || ''} |
830
|
|
|
title={t('Reporting Period Decreased CATEGORY (Baseline - Actual) UNIT', { 'CATEGORY': t('Ton of Carbon Dioxide Emissions'), 'UNIT': '(TCO2E)' })} |
831
|
|
|
color="warning" |
832
|
|
|
footnote={t('Per Unit Area')} |
833
|
|
|
footvalue={totalInTCO2E['value_per_unit_area']} |
834
|
|
|
footunit="(TCO2E/M²)"> |
835
|
|
|
{totalInTCO2E['value'] && <CountUp end={totalInTCO2E['value']} duration={2} prefix="" separator="," decimal="." decimals={2} />} |
836
|
|
|
</CardSummary> |
837
|
|
|
</div> |
838
|
|
|
<Row noGutters> |
839
|
|
|
<Col className="mb-3 pr-lg-2 mb-3"> |
840
|
|
|
<SharePie data={TCEShareData} title={t('Ton of Standard Coal by Energy Category')} /> |
841
|
|
|
</Col> |
842
|
|
|
<Col className="mb-3 pr-lg-2 mb-3"> |
843
|
|
|
<SharePie data={TCO2EShareData} title={t('Ton of Carbon Dioxide Emissions by Energy Category')} /> |
844
|
|
|
</Col> |
845
|
|
|
</Row> |
846
|
|
|
|
847
|
|
|
<MultiTrendChart reportingTitle = {{"name": "Reporting Period Saving CATEGORY VALUE UNIT", "substitute": ["CATEGORY", "VALUE", "UNIT"], "CATEGORY": shopfloorBaseAndReportingNames, "VALUE": shopfloorReportingSubtotals, "UNIT": shopfloorBaseAndReportingUnits}} |
848
|
|
|
baseTitle = {{"name": "Base Period Saving CATEGORY VALUE UNIT", "substitute": ["CATEGORY", "VALUE", "UNIT"], "CATEGORY": shopfloorBaseAndReportingNames, "VALUE": shopfloorBaseSubtotals, "UNIT": shopfloorBaseAndReportingUnits}} |
849
|
|
|
reportingTooltipTitle = {{"name": "Reporting Period Saving CATEGORY VALUE UNIT", "substitute": ["CATEGORY", "VALUE", "UNIT"], "CATEGORY": shopfloorBaseAndReportingNames, "VALUE": null, "UNIT": shopfloorBaseAndReportingUnits}} |
850
|
|
|
baseTooltipTitle = {{"name": "Base Period Saving CATEGORY VALUE UNIT", "substitute": ["CATEGORY", "VALUE", "UNIT"], "CATEGORY": shopfloorBaseAndReportingNames, "VALUE": null, "UNIT": shopfloorBaseAndReportingUnits}} |
851
|
|
|
reportingLabels={shopfloorReportingLabels} |
852
|
|
|
reportingData={shopfloorReportingData} |
853
|
|
|
baseLabels={shopfloorBaseLabels} |
854
|
|
|
baseData={shopfloorBaseData} |
855
|
|
|
rates={shopfloorReportingRates} |
856
|
|
|
options={shopfloorReportingOptions}> |
857
|
|
|
</MultiTrendChart> |
858
|
|
|
|
859
|
|
|
<MultipleLineChart reportingTitle={t('Related Parameters')} |
860
|
|
|
baseTitle='' |
861
|
|
|
labels={parameterLineChartLabels} |
862
|
|
|
data={parameterLineChartData} |
863
|
|
|
options={parameterLineChartOptions}> |
864
|
|
|
</MultipleLineChart> |
865
|
|
|
<br /> |
866
|
|
|
<DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={50} > |
867
|
|
|
</DetailedDataTable> |
868
|
|
|
|
869
|
|
|
</Fragment> |
870
|
|
|
); |
871
|
|
|
}; |
872
|
|
|
|
873
|
|
|
export default withTranslation()(withRedirect(ShopfloorSaving)); |
874
|
|
|
|