Merge branch 'dev-bagus' of https://github.com/defuj/eis into dev-defuj
This commit is contained in:
commit
1878eef2fd
@ -3715,16 +3715,6 @@ body {
|
|||||||
color: rgb(102 102 0 / var(--tw-text-opacity));
|
color: rgb(102 102 0 / var(--tw-text-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-slate-300 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(203 213 225 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-slate-500 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(100 116 139 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-opacity-40 {
|
.text-opacity-40 {
|
||||||
--tw-text-opacity: 0.4;
|
--tw-text-opacity: 0.4;
|
||||||
}
|
}
|
||||||
@ -3733,10 +3723,6 @@ body {
|
|||||||
text-decoration-line: underline;
|
text-decoration-line: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-underline {
|
|
||||||
text-decoration-line: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.placeholder-gray-500::-moz-placeholder {
|
.placeholder-gray-500::-moz-placeholder {
|
||||||
--tw-placeholder-opacity: 1;
|
--tw-placeholder-opacity: 1;
|
||||||
color: rgb(107 114 128 / var(--tw-placeholder-opacity));
|
color: rgb(107 114 128 / var(--tw-placeholder-opacity));
|
||||||
@ -5266,11 +5252,6 @@ body {
|
|||||||
color: rgb(51 51 0 / 0.9);
|
color: rgb(51 51 0 / 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
:is(.dark .dark\:text-slate-500) {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(100 116 139 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
:is(.dark .dark\:text-opacity-70) {
|
:is(.dark .dark\:text-opacity-70) {
|
||||||
--tw-text-opacity: 0.7;
|
--tw-text-opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,4 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
@ -25,247 +12,171 @@ const reportName = 'Rekapitulasi Gangguan All'
|
|||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
const detailFontSize = 3
|
const detailFontSize = 3
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
if (reportMeta.posko.id != 0) {
|
||||||
|
return {
|
||||||
data.forEach((item: any) => {
|
parent: reportMeta.up3.name,
|
||||||
const { nama_regional, nama_uid } = item
|
summaryName: reportMeta.posko.name,
|
||||||
|
summaryKey: 'nama_posko'
|
||||||
if (!groupedData[nama_regional]) {
|
|
||||||
groupedData[nama_regional] = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!groupedData[nama_regional][nama_uid]) {
|
|
||||||
groupedData[nama_regional][nama_uid] = { data: [] }
|
|
||||||
}
|
|
||||||
|
|
||||||
groupedData[nama_regional][nama_uid].data.push(item)
|
|
||||||
})
|
|
||||||
|
|
||||||
for (const regional in groupedData) {
|
|
||||||
for (const uid in groupedData[regional]) {
|
|
||||||
const data = groupedData[regional][uid].data
|
|
||||||
|
|
||||||
data.forEach((item: any) => {
|
|
||||||
if (!groupedData[regional][uid].summary) {
|
|
||||||
groupedData[regional][uid].summary = {
|
|
||||||
total: 0,
|
|
||||||
total_selesai: 0,
|
|
||||||
total_inproses: 0,
|
|
||||||
avg_durasi_dispatch: [],
|
|
||||||
max_durasi_dispatch: 0,
|
|
||||||
min_durasi_dispatch: item.min_durasi_dispatch,
|
|
||||||
total_diatas_sla_dispatch: 0,
|
|
||||||
total_dibawah_sla_dispatch: 0,
|
|
||||||
avg_durasi_response: [],
|
|
||||||
max_durasi_response: 0,
|
|
||||||
min_durasi_response: item.min_durasi_response,
|
|
||||||
total_diatas_sla_response: 0,
|
|
||||||
total_dibawah_sla_response: 0,
|
|
||||||
avg_durasi_recovery: [],
|
|
||||||
max_durasi_recovery: 0,
|
|
||||||
min_durasi_recovery: item.min_durasi_recovery,
|
|
||||||
total_diatas_sla_recovery: 0,
|
|
||||||
total_dibawah_sla_recovery: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
groupedData[regional][uid].summary.total += item.total
|
|
||||||
groupedData[regional][uid].summary.total_selesai += item.total_selesai
|
|
||||||
groupedData[regional][uid].summary.total_inproses += item.total_inproses
|
|
||||||
groupedData[regional][uid].summary.avg_durasi_dispatch.push(item.avg_durasi_dispatch)
|
|
||||||
groupedData[regional][uid].summary.max_durasi_dispatch =
|
|
||||||
groupedData[regional][uid].summary.max_durasi_dispatch < item.max_durasi_dispatch
|
|
||||||
? item.max_durasi_dispatch
|
|
||||||
: groupedData[regional][uid].summary.max_durasi_dispatch
|
|
||||||
groupedData[regional][uid].summary.min_durasi_dispatch =
|
|
||||||
groupedData[regional][uid].summary.min_durasi_dispatch > item.min_durasi_dispatch
|
|
||||||
? item.min_durasi_dispatch
|
|
||||||
: groupedData[regional][uid].summary.min_durasi_dispatch
|
|
||||||
groupedData[regional][uid].summary.total_diatas_sla_dispatch +=
|
|
||||||
item.total_diatas_sla_dispatch
|
|
||||||
groupedData[regional][uid].summary.total_dibawah_sla_dispatch +=
|
|
||||||
item.total_dibawah_sla_dispatch
|
|
||||||
groupedData[regional][uid].summary.avg_durasi_response.push(item.avg_durasi_response)
|
|
||||||
groupedData[regional][uid].summary.max_durasi_response =
|
|
||||||
groupedData[regional][uid].summary.max_durasi_response < item.max_durasi_response
|
|
||||||
? item.max_durasi_response
|
|
||||||
: groupedData[regional][uid].summary.max_durasi_response
|
|
||||||
groupedData[regional][uid].summary.min_durasi_response =
|
|
||||||
groupedData[regional][uid].summary.min_durasi_response > item.min_durasi_response
|
|
||||||
? item.min_durasi_response
|
|
||||||
: groupedData[regional][uid].summary.min_durasi_response
|
|
||||||
groupedData[regional][uid].summary.total_diatas_sla_response +=
|
|
||||||
item.total_diatas_sla_response
|
|
||||||
groupedData[regional][uid].summary.total_dibawah_sla_response +=
|
|
||||||
item.total_dibawah_sla_response
|
|
||||||
groupedData[regional][uid].summary.avg_durasi_recovery.push(item.avg_durasi_recovery)
|
|
||||||
groupedData[regional][uid].summary.max_durasi_recovery =
|
|
||||||
groupedData[regional][uid].summary.max_durasi_recovery < item.max_durasi_recovery
|
|
||||||
? item.max_durasi_recovery
|
|
||||||
: groupedData[regional][uid].summary.max_durasi_recovery
|
|
||||||
groupedData[regional][uid].summary.min_durasi_recovery =
|
|
||||||
groupedData[regional][uid].summary.min_durasi_recovery > item.min_durasi_recovery
|
|
||||||
? item.min_durasi_recovery
|
|
||||||
: groupedData[regional][uid].summary.min_durasi_recovery
|
|
||||||
groupedData[regional][uid].summary.total_diatas_sla_recovery +=
|
|
||||||
item.total_diatas_sla_recovery
|
|
||||||
groupedData[regional][uid].summary.total_dibawah_sla_recovery +=
|
|
||||||
item.total_dibawah_sla_recovery
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: 'regional',
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
const groupedData: any = {}
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
for (const regional in data) {
|
let parentName = ''
|
||||||
let no = 1
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
const total: any = {
|
|
||||||
total: 0,
|
|
||||||
total_selesai: 0,
|
|
||||||
persen_selesai: 0,
|
|
||||||
total_inproses: 0,
|
|
||||||
persen_inproses: 0,
|
|
||||||
avg_durasi_dispatch: [],
|
|
||||||
max_durasi_dispatch: [],
|
|
||||||
min_durasi_dispatch: [],
|
|
||||||
total_diatas_sla_dispatch: 0,
|
|
||||||
total_dibawah_sla_dispatch: 0,
|
|
||||||
avg_durasi_response: [],
|
|
||||||
max_durasi_response: [],
|
|
||||||
min_durasi_response: [],
|
|
||||||
total_diatas_sla_response: 0,
|
|
||||||
total_dibawah_sla_response: 0,
|
|
||||||
avg_durasi_recovery: [],
|
|
||||||
max_durasi_recovery: [],
|
|
||||||
min_durasi_recovery: [],
|
|
||||||
total_diatas_sla_recovery: 0,
|
|
||||||
total_dibawah_sla_recovery: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
formattedData.push([{ content: regional, colSpan: 22, styles: { fontStyle: 'bold' } }])
|
if (tempData.parent === '') {
|
||||||
|
parentName = 'Seluruh Unit'
|
||||||
for (const uid in data[regional]) {
|
} else if (tempData.parent === 'regional') {
|
||||||
const summary = data[regional][uid].summary
|
parentName = tempData.data[tempData.summaryName][0].nama_regional
|
||||||
const avgDurasiDispatch = summary.avg_durasi_dispatch.length
|
} else {
|
||||||
? summary.avg_durasi_dispatch.reduce((a: any, b: any) => a + b) /
|
parentName = tempData.parent
|
||||||
summary.avg_durasi_dispatch.length
|
|
||||||
: 0
|
|
||||||
const avgDurasiResponse = summary.avg_durasi_response.length
|
|
||||||
? summary.avg_durasi_response.reduce((a: any, b: any) => a + b) /
|
|
||||||
summary.avg_durasi_response.length
|
|
||||||
: 0
|
|
||||||
const avgDurasiRecovery = summary.avg_durasi_recovery.length
|
|
||||||
? summary.avg_durasi_recovery.reduce((a: any, b: any) => a + b) /
|
|
||||||
summary.avg_durasi_recovery.length
|
|
||||||
: 0
|
|
||||||
|
|
||||||
formattedData.push([
|
|
||||||
{ content: no++, styles: { halign: 'right' } },
|
|
||||||
uid,
|
|
||||||
formatNumber(summary.total),
|
|
||||||
formatNumber(summary.total_selesai),
|
|
||||||
summary.total_selesai != summary.total
|
|
||||||
? formatPercentage((summary.total_selesai / summary.total) * 100)
|
|
||||||
: '100%',
|
|
||||||
formatNumber(summary.total_inproses),
|
|
||||||
formatPercentage(
|
|
||||||
!summary.total_inproses || !summary.total
|
|
||||||
? '0%'
|
|
||||||
: (summary.total_inproses / summary.total) * 100
|
|
||||||
),
|
|
||||||
formatNumber(avgDurasiDispatch),
|
|
||||||
formatWaktu(summary.max_durasi_dispatch),
|
|
||||||
formatWaktu(summary.min_durasi_dispatch),
|
|
||||||
formatNumber(summary.total_diatas_sla_dispatch),
|
|
||||||
formatNumber(summary.total_dibawah_sla_dispatch),
|
|
||||||
formatNumber(avgDurasiResponse),
|
|
||||||
formatWaktu(summary.max_durasi_response),
|
|
||||||
formatWaktu(summary.min_durasi_response),
|
|
||||||
formatNumber(summary.total_diatas_sla_response),
|
|
||||||
formatNumber(summary.total_dibawah_sla_response),
|
|
||||||
formatNumber(avgDurasiRecovery),
|
|
||||||
formatWaktu(summary.max_durasi_recovery),
|
|
||||||
formatWaktu(summary.min_durasi_recovery),
|
|
||||||
formatNumber(summary.total_diatas_sla_recovery),
|
|
||||||
formatNumber(summary.total_dibawah_sla_recovery)
|
|
||||||
])
|
|
||||||
|
|
||||||
total.total += summary.total
|
|
||||||
total.total_selesai += summary.total_selesai
|
|
||||||
total.total_inproses += summary.total_inproses
|
|
||||||
total.avg_durasi_dispatch.push(avgDurasiDispatch)
|
|
||||||
|
|
||||||
total.max_durasi_dispatch.push(summary.max_durasi_dispatch)
|
|
||||||
total.min_durasi_dispatch.push(summary.min_durasi_dispatch)
|
|
||||||
|
|
||||||
total.total_diatas_sla_dispatch += summary.total_diatas_sla_dispatch
|
|
||||||
total.total_dibawah_sla_dispatch += summary.total_dibawah_sla_dispatch
|
|
||||||
total.avg_durasi_response.push(avgDurasiResponse)
|
|
||||||
|
|
||||||
total.max_durasi_response.push(summary.max_durasi_response)
|
|
||||||
total.min_durasi_response.push(summary.min_durasi_response)
|
|
||||||
|
|
||||||
total.total_diatas_sla_response += summary.total_diatas_sla_response
|
|
||||||
total.total_dibawah_sla_response += summary.total_dibawah_sla_response
|
|
||||||
total.avg_durasi_recovery.push(avgDurasiRecovery)
|
|
||||||
|
|
||||||
total.max_durasi_recovery.push(summary.max_durasi_recovery)
|
|
||||||
total.min_durasi_recovery.push(summary.min_durasi_recovery)
|
|
||||||
|
|
||||||
total.total_diatas_sla_recovery += summary.total_diatas_sla_recovery
|
|
||||||
total.total_dibawah_sla_recovery += summary.total_dibawah_sla_recovery
|
|
||||||
}
|
|
||||||
|
|
||||||
formattedData.push([
|
|
||||||
{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } },
|
|
||||||
formatNumber(total.total),
|
|
||||||
formatNumber(total.total_selesai),
|
|
||||||
formatPercentage(
|
|
||||||
!total.total_selesai || !total.total ? '0%' : (total.total_selesai / total.total) * 100
|
|
||||||
),
|
|
||||||
formatNumber(total.total_inproses),
|
|
||||||
formatPercentage(
|
|
||||||
!total.total_inproses || !total.total ? '0%' : (total.total_inproses / total.total) * 100
|
|
||||||
),
|
|
||||||
formatNumber(
|
|
||||||
total.avg_durasi_dispatch.length
|
|
||||||
? total.avg_durasi_dispatch.reduce((a: any, b: any) => a + b) /
|
|
||||||
total.avg_durasi_dispatch.length
|
|
||||||
: 0
|
|
||||||
),
|
|
||||||
formatWaktu(Math.max(...total.max_durasi_dispatch)),
|
|
||||||
formatWaktu(Math.min(...total.min_durasi_dispatch)),
|
|
||||||
formatNumber(total.total_diatas_sla_dispatch),
|
|
||||||
formatNumber(total.total_dibawah_sla_dispatch),
|
|
||||||
formatNumber(
|
|
||||||
total.avg_durasi_response.length
|
|
||||||
? total.avg_durasi_response.reduce((a: any, b: any) => a + b) /
|
|
||||||
total.avg_durasi_response.length
|
|
||||||
: 0
|
|
||||||
),
|
|
||||||
formatWaktu(Math.max(...total.max_durasi_response)),
|
|
||||||
formatWaktu(Math.min(...total.min_durasi_response)),
|
|
||||||
formatNumber(total.total_diatas_sla_response),
|
|
||||||
formatNumber(total.total_dibawah_sla_response),
|
|
||||||
formatNumber(
|
|
||||||
total.avg_durasi_recovery.length
|
|
||||||
? total.avg_durasi_recovery.reduce((a: any, b: any) => a + b) /
|
|
||||||
total.avg_durasi_recovery.length
|
|
||||||
: 0
|
|
||||||
),
|
|
||||||
formatWaktu(Math.max(...total.max_durasi_recovery)),
|
|
||||||
formatWaktu(Math.min(...total.min_durasi_recovery)),
|
|
||||||
formatNumber(total.total_diatas_sla_recovery),
|
|
||||||
formatNumber(total.total_dibawah_sla_recovery)
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const total: any = {
|
||||||
|
total: 0,
|
||||||
|
total_selesai: 0,
|
||||||
|
// persen_selesai: 0,
|
||||||
|
total_inproses: 0,
|
||||||
|
// persen_inproses: 0,
|
||||||
|
avg_durasi_dispatch: [],
|
||||||
|
max_durasi_dispatch: [],
|
||||||
|
min_durasi_dispatch: [],
|
||||||
|
total_diatas_sla_dispatch: 0,
|
||||||
|
total_dibawah_sla_dispatch: 0,
|
||||||
|
avg_durasi_response: [],
|
||||||
|
max_durasi_response: [],
|
||||||
|
min_durasi_response: [],
|
||||||
|
total_diatas_sla_response: 0,
|
||||||
|
total_dibawah_sla_response: 0,
|
||||||
|
avg_durasi_recovery: [],
|
||||||
|
max_durasi_recovery: [],
|
||||||
|
min_durasi_recovery: [],
|
||||||
|
total_diatas_sla_recovery: 0,
|
||||||
|
total_dibawah_sla_recovery: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.total += item.total
|
||||||
|
total.total_selesai += item.total_selesai
|
||||||
|
total.total_inproses += item.total_inproses
|
||||||
|
total.avg_durasi_dispatch.push(item.avg_durasi_dispatch)
|
||||||
|
total.max_durasi_dispatch.push(item.max_durasi_dispatch)
|
||||||
|
total.min_durasi_dispatch.push(item.min_durasi_dispatch)
|
||||||
|
total.total_diatas_sla_dispatch += item.total_diatas_sla_dispatch
|
||||||
|
total.total_dibawah_sla_dispatch += item.total_dibawah_sla_dispatch
|
||||||
|
total.avg_durasi_response.push(item.avg_durasi_response)
|
||||||
|
total.max_durasi_response.push(item.max_durasi_response)
|
||||||
|
total.min_durasi_response.push(item.min_durasi_response)
|
||||||
|
total.total_diatas_sla_response += item.total_diatas_sla_response
|
||||||
|
total.total_dibawah_sla_response += item.total_dibawah_sla_response
|
||||||
|
total.avg_durasi_recovery.push(item.avg_durasi_recovery)
|
||||||
|
total.max_durasi_recovery.push(item.max_durasi_recovery)
|
||||||
|
total.min_durasi_recovery.push(item.min_durasi_recovery)
|
||||||
|
total.total_diatas_sla_recovery += item.total_diatas_sla_recovery
|
||||||
|
total.total_dibawah_sla_recovery += item.total_dibawah_sla_recovery
|
||||||
|
})
|
||||||
|
|
||||||
|
const persenSelesai =
|
||||||
|
total.total_selesai != total.total ? (total.total_selesai / total.total) * 100 : 100
|
||||||
|
const persenInproses =
|
||||||
|
total.total_inproses != total.total ? (total.total_inproses / total.total) * 100 : 100
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 22, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(total.total),
|
||||||
|
formatNumber(total.total_selesai),
|
||||||
|
formatPercentage(persenSelesai),
|
||||||
|
formatNumber(total.total_inproses),
|
||||||
|
formatPercentage(persenInproses),
|
||||||
|
formatNumber(
|
||||||
|
total.avg_durasi_dispatch.length
|
||||||
|
? total.avg_durasi_dispatch.reduce((a: any, b: any) => a + b) /
|
||||||
|
total.avg_durasi_dispatch.length
|
||||||
|
: 0
|
||||||
|
),
|
||||||
|
formatWaktu(Math.max(...total.max_durasi_dispatch)),
|
||||||
|
formatWaktu(Math.min(...total.min_durasi_dispatch)),
|
||||||
|
formatNumber(total.total_diatas_sla_dispatch),
|
||||||
|
formatNumber(total.total_dibawah_sla_dispatch),
|
||||||
|
formatNumber(
|
||||||
|
total.avg_durasi_response.length
|
||||||
|
? total.avg_durasi_response.reduce((a: any, b: any) => a + b) /
|
||||||
|
total.avg_durasi_response.length
|
||||||
|
: 0
|
||||||
|
),
|
||||||
|
formatWaktu(Math.max(...total.max_durasi_response)),
|
||||||
|
formatWaktu(Math.min(...total.min_durasi_response)),
|
||||||
|
formatNumber(total.total_diatas_sla_response),
|
||||||
|
formatNumber(total.total_dibawah_sla_response),
|
||||||
|
formatNumber(
|
||||||
|
total.avg_durasi_recovery.length
|
||||||
|
? total.avg_durasi_recovery.reduce((a: any, b: any) => a + b) /
|
||||||
|
total.avg_durasi_recovery.length
|
||||||
|
: 0
|
||||||
|
),
|
||||||
|
formatWaktu(Math.max(...total.max_durasi_recovery)),
|
||||||
|
formatWaktu(Math.min(...total.min_durasi_recovery)),
|
||||||
|
formatNumber(total.total_diatas_sla_recovery),
|
||||||
|
formatNumber(total.total_dibawah_sla_recovery)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } }, ...result])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,12 +206,11 @@ const formatMetaData = (reportMeta: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
console.log(data)
|
|
||||||
autoTable(doc, {
|
autoTable(doc, {
|
||||||
head: [
|
head: [
|
||||||
['PT. PLN(Persero)', '', ''],
|
['PT. PLN(Persero)', '', ''],
|
||||||
@ -643,25 +553,28 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
2,
|
2,
|
||||||
1,
|
1,
|
||||||
`UNIT INDUK : ${reportMeta.uid
|
`UNIT INDUK : ${
|
||||||
? reportMeta.uid.name.toUpperCase()
|
reportMeta.uid
|
||||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
? reportMeta.uid.name.toUpperCase()
|
||||||
|
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
setHeaderStyle(
|
setHeaderStyle(
|
||||||
worksheet,
|
worksheet,
|
||||||
3,
|
3,
|
||||||
1,
|
1,
|
||||||
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${reportMeta.up3
|
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
|
||||||
? reportMeta.up3.name.toUpperCase()
|
reportMeta.up3
|
||||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
? reportMeta.up3.name.toUpperCase()
|
||||||
|
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
setHeaderStyle(
|
setHeaderStyle(
|
||||||
worksheet,
|
worksheet,
|
||||||
4,
|
4,
|
||||||
1,
|
1,
|
||||||
`POSKO : ${reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()
|
`POSKO : ${
|
||||||
|
reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -736,9 +649,16 @@ const exportDetailToXLSX = (reportMeta: any, e: any) => {
|
|||||||
e.cancel = true
|
e.cancel = true
|
||||||
}
|
}
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), reportName, formatMetaData(reportMeta))
|
exportToWord(reportMeta, formatData(rawData, reportMeta), reportName, formatMetaData(reportMeta))
|
||||||
}
|
}
|
||||||
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportDetailToWord(reportMeta, rawData, `Detail ${reportName}`, formatMetaData(reportMeta))
|
exportDetailToWord(reportMeta, rawData, `Detail ${reportName}`, formatMetaData(reportMeta))
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX, exportDetailToPDF, exportDetailToXLSX, exportToDOCX, exportDetailToDOCX }
|
export {
|
||||||
|
exportToPDF,
|
||||||
|
exportToXLSX,
|
||||||
|
exportDetailToPDF,
|
||||||
|
exportDetailToXLSX,
|
||||||
|
exportToDOCX,
|
||||||
|
exportDetailToDOCX
|
||||||
|
}
|
||||||
|
@ -25,192 +25,149 @@ const reportName = 'Rekapitulasi Keluhan All'
|
|||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
const detailFontSize = 5
|
const detailFontSize = 5
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
data.forEach((item: any) => {
|
parent: reportMeta.up3.name,
|
||||||
const { nama_regional, nama_uid } = item
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
if (!groupedData[nama_regional]) {
|
|
||||||
groupedData[nama_regional] = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!groupedData[nama_regional][nama_uid]) {
|
|
||||||
groupedData[nama_regional][nama_uid] = { data: [] }
|
|
||||||
}
|
|
||||||
|
|
||||||
groupedData[nama_regional][nama_uid].data.push(item)
|
|
||||||
})
|
|
||||||
|
|
||||||
for (const regional in groupedData) {
|
|
||||||
for (const uid in groupedData[regional]) {
|
|
||||||
const data = groupedData[regional][uid].data
|
|
||||||
|
|
||||||
data.forEach((item: any) => {
|
|
||||||
if (!groupedData[regional][uid].summary) {
|
|
||||||
groupedData[regional][uid].summary = {
|
|
||||||
total: 0,
|
|
||||||
total_selesai: 0,
|
|
||||||
total_inproses: 0,
|
|
||||||
avg_durasi_response: [],
|
|
||||||
max_durasi_response: 0,
|
|
||||||
min_durasi_response: 0,
|
|
||||||
total_diatas_sla_response: 0,
|
|
||||||
total_dibawah_sla_response: 0,
|
|
||||||
avg_durasi_recovery: [],
|
|
||||||
max_durasi_recovery: 0,
|
|
||||||
min_durasi_recovery: 0,
|
|
||||||
total_diatas_sla_recovery: 0,
|
|
||||||
total_dibawah_sla_recovery: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
groupedData[regional][uid].summary.total += item.total
|
|
||||||
groupedData[regional][uid].summary.total_selesai += item.total_selesai
|
|
||||||
groupedData[regional][uid].summary.total_inproses += item.total_inproses
|
|
||||||
groupedData[regional][uid].summary.avg_durasi_response.push(item.avg_durasi_response)
|
|
||||||
groupedData[regional][uid].summary.max_durasi_response =
|
|
||||||
groupedData[regional][uid].summary.max_durasi_response < item.max_durasi_response
|
|
||||||
? item.max_durasi_response
|
|
||||||
: groupedData[regional][uid].summary.max_durasi_response
|
|
||||||
groupedData[regional][uid].summary.min_durasi_response =
|
|
||||||
groupedData[regional][uid].summary.min_durasi_response > item.min_durasi_response
|
|
||||||
? item.min_durasi_response
|
|
||||||
: groupedData[regional][uid].summary.min_durasi_response
|
|
||||||
groupedData[regional][uid].summary.total_diatas_sla_response +=
|
|
||||||
item.total_diatas_sla_response
|
|
||||||
groupedData[regional][uid].summary.total_dibawah_sla_response +=
|
|
||||||
item.total_dibawah_sla_response
|
|
||||||
groupedData[regional][uid].summary.avg_durasi_recovery.push(item.avg_durasi_recovery)
|
|
||||||
groupedData[regional][uid].summary.max_durasi_recovery =
|
|
||||||
groupedData[regional][uid].summary.max_durasi_recovery < item.max_durasi_recovery
|
|
||||||
? item.max_durasi_recovery
|
|
||||||
: groupedData[regional][uid].summary.max_durasi_recovery
|
|
||||||
groupedData[regional][uid].summary.min_durasi_recovery =
|
|
||||||
groupedData[regional][uid].summary.min_durasi_recovery > item.min_durasi_recovery
|
|
||||||
? item.min_durasi_recovery
|
|
||||||
: groupedData[regional][uid].summary.min_durasi_recovery
|
|
||||||
groupedData[regional][uid].summary.total_diatas_sla_recovery +=
|
|
||||||
item.total_diatas_sla_recovery
|
|
||||||
groupedData[regional][uid].summary.total_dibawah_sla_recovery +=
|
|
||||||
item.total_dibawah_sla_recovery
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: 'regional',
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
const groupedData: any = {}
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
for (const regional in data) {
|
let parentName = ''
|
||||||
let no = 1
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
const total: any = {
|
|
||||||
total: 0,
|
|
||||||
total_selesai: 0,
|
|
||||||
total_inproses: 0,
|
|
||||||
avg_durasi_response: [],
|
|
||||||
max_durasi_response: [],
|
|
||||||
min_durasi_response: [],
|
|
||||||
total_diatas_sla_response: 0,
|
|
||||||
total_dibawah_sla_response: 0,
|
|
||||||
avg_durasi_recovery: [],
|
|
||||||
max_durasi_recovery: [],
|
|
||||||
min_durasi_recovery: [],
|
|
||||||
total_diatas_sla_recovery: 0,
|
|
||||||
total_dibawah_sla_recovery: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
formattedData.push([{ content: regional, colSpan: 17, styles: { fontStyle: 'bold' } }])
|
if (tempData.parent === '') {
|
||||||
|
parentName = 'Seluruh Distribusi'
|
||||||
for (const uid in data[regional]) {
|
} else if (tempData.parent === 'regional') {
|
||||||
const summary = data[regional][uid].summary
|
parentName = tempData.data[tempData.summaryName][0].nama_regional
|
||||||
const avgDurasiResponse = summary.avg_durasi_response.length
|
} else {
|
||||||
? summary.avg_durasi_response.reduce((a: any, b: any) => a + b) /
|
parentName = tempData.parent
|
||||||
summary.avg_durasi_response.length
|
|
||||||
: 0
|
|
||||||
const avgDurasiRecovery = summary.avg_durasi_recovery.length
|
|
||||||
? summary.avg_durasi_recovery.reduce((a: any, b: any) => a + b) /
|
|
||||||
summary.avg_durasi_recovery.length
|
|
||||||
: 0
|
|
||||||
|
|
||||||
formattedData.push([
|
|
||||||
{ content: no++, styles: { halign: 'right' } },
|
|
||||||
uid,
|
|
||||||
formatNumber(summary.total),
|
|
||||||
formatNumber(summary.total_selesai),
|
|
||||||
summary.total_selesai != summary.total
|
|
||||||
? formatPercentage((summary.total_selesai / summary.total) * 100)
|
|
||||||
: '100%',
|
|
||||||
formatNumber(summary.total_inproses),
|
|
||||||
formatPercentage(
|
|
||||||
!summary.total_inproses || !summary.total
|
|
||||||
? '0%'
|
|
||||||
: (summary.total_inproses / summary.total) * 100
|
|
||||||
),
|
|
||||||
formatNumber(avgDurasiResponse),
|
|
||||||
formatWaktu(summary.max_durasi_response),
|
|
||||||
formatWaktu(summary.min_durasi_response),
|
|
||||||
formatNumber(summary.total_diatas_sla_response),
|
|
||||||
formatNumber(summary.total_dibawah_sla_response),
|
|
||||||
formatNumber(avgDurasiRecovery),
|
|
||||||
formatWaktu(summary.max_durasi_recovery),
|
|
||||||
formatWaktu(summary.min_durasi_recovery),
|
|
||||||
formatNumber(summary.total_diatas_sla_recovery),
|
|
||||||
formatNumber(summary.total_dibawah_sla_recovery)
|
|
||||||
])
|
|
||||||
|
|
||||||
total.total += summary.total
|
|
||||||
total.total_selesai += summary.total_selesai
|
|
||||||
total.total_inproses += summary.total_inproses
|
|
||||||
total.avg_durasi_response.push(avgDurasiResponse)
|
|
||||||
total.max_durasi_response.push(summary.max_durasi_response)
|
|
||||||
total.min_durasi_response.push(summary.min_durasi_response)
|
|
||||||
total.total_diatas_sla_response += summary.total_diatas_sla_response
|
|
||||||
total.total_dibawah_sla_response += summary.total_dibawah_sla_response
|
|
||||||
total.avg_durasi_recovery.push(avgDurasiRecovery)
|
|
||||||
total.max_durasi_recovery.push(summary.max_durasi_recovery)
|
|
||||||
total.min_durasi_recovery.push(summary.min_durasi_recovery)
|
|
||||||
total.total_diatas_sla_recovery += summary.total_diatas_sla_recovery
|
|
||||||
total.total_dibawah_sla_recovery += summary.total_dibawah_sla_recovery
|
|
||||||
}
|
|
||||||
|
|
||||||
formattedData.push([
|
|
||||||
{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } },
|
|
||||||
formatNumber(total.total),
|
|
||||||
formatNumber(total.total_selesai),
|
|
||||||
formatPercentage(
|
|
||||||
!total.total_selesai || !total.total ? '0%' : (total.total_selesai / total.total) * 100
|
|
||||||
),
|
|
||||||
formatNumber(total.total_inproses),
|
|
||||||
formatPercentage(
|
|
||||||
!total.total_inproses || !total.total ? '0%' : (total.total_inproses / total.total) * 100
|
|
||||||
),
|
|
||||||
formatNumber(
|
|
||||||
total.avg_durasi_response.length
|
|
||||||
? total.avg_durasi_response.reduce((a: any, b: any) => a + b) /
|
|
||||||
total.avg_durasi_response.length
|
|
||||||
: 0
|
|
||||||
),
|
|
||||||
formatWaktu(Math.max(...total.max_durasi_response)),
|
|
||||||
formatWaktu(Math.min(...total.min_durasi_response)),
|
|
||||||
formatNumber(total.total_diatas_sla_response),
|
|
||||||
formatNumber(total.total_dibawah_sla_response),
|
|
||||||
formatNumber(
|
|
||||||
total.avg_durasi_recovery.length
|
|
||||||
? total.avg_durasi_recovery.reduce((a: any, b: any) => a + b) /
|
|
||||||
total.avg_durasi_recovery.length
|
|
||||||
: 0
|
|
||||||
),
|
|
||||||
formatWaktu(Math.max(...total.max_durasi_recovery)),
|
|
||||||
formatWaktu(Math.min(...total.min_durasi_recovery)),
|
|
||||||
formatNumber(total.total_diatas_sla_recovery),
|
|
||||||
formatNumber(total.total_dibawah_sla_recovery)
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const total: any = {
|
||||||
|
total: 0,
|
||||||
|
total_selesai: 0,
|
||||||
|
total_inproses: 0,
|
||||||
|
avg_durasi_response: [],
|
||||||
|
max_durasi_response: [],
|
||||||
|
min_durasi_response: [],
|
||||||
|
total_diatas_sla_response: 0,
|
||||||
|
total_dibawah_sla_response: 0,
|
||||||
|
avg_durasi_recovery: [],
|
||||||
|
max_durasi_recovery: [],
|
||||||
|
min_durasi_recovery: [],
|
||||||
|
total_diatas_sla_recovery: 0,
|
||||||
|
total_dibawah_sla_recovery: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.total += item.total
|
||||||
|
total.total_selesai += item.total_selesai
|
||||||
|
total.total_inproses += item.total_inproses
|
||||||
|
total.avg_durasi_response.push(item.avg_durasi_response)
|
||||||
|
total.max_durasi_response.push(item.max_durasi_response)
|
||||||
|
total.min_durasi_response.push(item.min_durasi_response)
|
||||||
|
total.total_diatas_sla_response += item.total_diatas_sla_response
|
||||||
|
total.total_dibawah_sla_response += item.total_dibawah_sla_response
|
||||||
|
total.avg_durasi_recovery.push(item.avg_durasi_recovery)
|
||||||
|
total.max_durasi_recovery.push(item.max_durasi_recovery)
|
||||||
|
total.min_durasi_recovery.push(item.min_durasi_recovery)
|
||||||
|
total.total_diatas_sla_recovery += item.total_diatas_sla_recovery
|
||||||
|
total.total_dibawah_sla_recovery += item.total_dibawah_sla_recovery
|
||||||
|
})
|
||||||
|
|
||||||
|
const persenSelesai =
|
||||||
|
total.total_selesai != total.total ? (total.total_selesai / total.total) * 100 : 100
|
||||||
|
const persenInproses =
|
||||||
|
total.total_inproses != total.total ? (total.total_inproses / total.total) * 100 : 0
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 17, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(total.total),
|
||||||
|
formatNumber(total.total_selesai),
|
||||||
|
formatPercentage(persenSelesai),
|
||||||
|
formatNumber(total.total_inproses),
|
||||||
|
formatPercentage(persenInproses),
|
||||||
|
formatNumber(
|
||||||
|
total.avg_durasi_response.length
|
||||||
|
? total.avg_durasi_response.reduce((a: any, b: any) => a + b) /
|
||||||
|
total.avg_durasi_response.length
|
||||||
|
: 0
|
||||||
|
),
|
||||||
|
formatWaktu(Math.max(...total.max_durasi_response)),
|
||||||
|
formatWaktu(Math.min(...total.min_durasi_response)),
|
||||||
|
formatNumber(total.total_diatas_sla_response),
|
||||||
|
formatNumber(total.total_dibawah_sla_response),
|
||||||
|
formatNumber(
|
||||||
|
total.avg_durasi_recovery.length
|
||||||
|
? total.avg_durasi_recovery.reduce((a: any, b: any) => a + b) /
|
||||||
|
total.avg_durasi_recovery.length
|
||||||
|
: 0
|
||||||
|
),
|
||||||
|
formatWaktu(Math.max(...total.max_durasi_recovery)),
|
||||||
|
formatWaktu(Math.min(...total.min_durasi_recovery)),
|
||||||
|
formatNumber(total.total_diatas_sla_recovery),
|
||||||
|
formatNumber(total.total_dibawah_sla_recovery)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } }, ...result])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,8 +197,7 @@ const formatMetaData = (reportMeta: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
console.log(data)
|
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
@ -650,7 +606,7 @@ const exportDetailToXLSX = (reportMeta: any, e: any) => {
|
|||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
exportToWord(reportMeta, meta, formatData(rawData), reportName)
|
exportToWord(reportMeta, meta, formatData(rawData, reportMeta), reportName)
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user