Merge branch 'main' of https://code.sdsdev.co.kr/SDSRV-IDP/sbt-idp into vietanh99-update-xlsx

This commit is contained in:
daovietanh99 2024-02-16 08:42:04 +07:00
commit 6e1a1d3988
3 changed files with 91 additions and 59 deletions

View File

@ -1,7 +1,7 @@
import type { TableColumnsType } from 'antd'; import type { TableColumnsType } from 'antd';
import { Table } from 'antd'; import { Table } from 'antd';
import React from 'react'; import React from 'react';
import { formatPercent, ensureMin, ensureMax } from 'utils/metric-format'; import { ensureMax, ensureMin, formatPercent } from 'utils/metric-format';
interface DataType { interface DataType {
key: React.Key; key: React.Key;
@ -43,7 +43,8 @@ const columns: TableColumnsType<DataType> = [
{ text: 'SEIN', value: 'SEIN' }, { text: 'SEIN', value: 'SEIN' },
], ],
filterMode: 'menu', filterMode: 'menu',
onFilter: (value: string, record) => record.subSidiaries.includes(String(value).toUpperCase()), onFilter: (value: string, record) =>
record.subSidiaries.includes(String(value).toUpperCase()),
}, },
{ {
title: 'OCR extraction date', title: 'OCR extraction date',
@ -62,13 +63,49 @@ const columns: TableColumnsType<DataType> = [
onFilter: (value: string, record) => record.extractionDate.includes(value), onFilter: (value: string, record) => record.extractionDate.includes(value),
}, },
{ {
title: 'OCR Images', title: 'Total OCR Received (Image Count)',
dataIndex: 'totalOCRReceived',
key: 'totalOCRReceived',
width: '130px',
className: 'hide-border-right',
render: (_, record) => {
return <span>{record.snImeiTC + record.invoiceTC}</span>;
},
},
{
title: '',
children: [
{
title: 'SN/IMEI',
dataIndex: 'snImeiTC',
key: 'snImeiTC',
width: '50px',
className: 'show-border-left',
},
{
title: 'Invoice',
dataIndex: 'invoiceTC',
key: 'invoiceTC',
width: '50px',
},
],
},
{
title: 'Total OCR Redemptions (Image Count)',
dataIndex: 'totalImages',
key: 'totalImages',
width: '130px',
className: 'hide-border-right',
},
{
title: '',
children: [ children: [
{ {
title: 'SN/IMEI', title: 'SN/IMEI',
dataIndex: 'snOrImeiNumber', dataIndex: 'snOrImeiNumber',
key: 'snOrImeiNumber', key: 'snOrImeiNumber',
width: '50px', width: '50px',
className: 'show-border-left',
}, },
{ {
title: 'Invoice', title: 'Invoice',
@ -78,12 +115,6 @@ const columns: TableColumnsType<DataType> = [
}, },
], ],
}, },
{
title: 'Total Images',
dataIndex: 'totalImages',
key: 'totalImages',
width: '130px',
},
{ {
title: 'Image Quality', title: 'Image Quality',
children: [ children: [
@ -94,12 +125,12 @@ const columns: TableColumnsType<DataType> = [
width: '50px', width: '50px',
}, },
{ {
title: '% Successful', title: 'Successful (%)',
dataIndex: 'successfulPercentage', dataIndex: 'successfulPercentage',
key: 'successfulPercentage', key: 'successfulPercentage',
width: '120px', width: '120px',
render: (_, record) => { render: (_, record) => {
return <span>{(record.successfulPercentage * 100)?.toFixed(2)}</span>; return <span>{formatPercent(record.successfulPercentage)}</span>;
}, },
}, },
{ {
@ -109,10 +140,10 @@ const columns: TableColumnsType<DataType> = [
width: '30px', width: '30px',
}, },
{ {
title: '% Bad', title: 'Bad (%)',
dataIndex: 'badPercentage', dataIndex: 'badPercentage',
key: 'badPercentage', key: 'badPercentage',
width: '60px', width: '80px',
render: (_, record) => { render: (_, record) => {
const isAbnormal = ensureMax(record.badPercentage, 0.1); const isAbnormal = ensureMax(record.badPercentage, 0.1);
return ( return (
@ -134,7 +165,7 @@ const columns: TableColumnsType<DataType> = [
key: 'snImeiAAR', key: 'snImeiAAR',
width: '130px', width: '130px',
render: (_, record) => { render: (_, record) => {
const isAbnormal = ensureMin(record.snImeiAAR, 0.95) const isAbnormal = ensureMin(record.snImeiAAR, 0.98);
return ( return (
<span style={{ color: isAbnormal ? 'red' : '' }}> <span style={{ color: isAbnormal ? 'red' : '' }}>
{formatPercent(record.snImeiAAR)} {formatPercent(record.snImeiAAR)}
@ -148,7 +179,7 @@ const columns: TableColumnsType<DataType> = [
key: 'purchaseDateAAR', key: 'purchaseDateAAR',
width: '130px', width: '130px',
render: (_, record) => { render: (_, record) => {
const isAbnormal = ensureMin(record.purchaseDateAAR, 0.95); const isAbnormal = ensureMin(record.purchaseDateAAR, 0.98);
return ( return (
<span style={{ color: isAbnormal ? 'red' : '' }}> <span style={{ color: isAbnormal ? 'red' : '' }}>
{formatPercent(record.purchaseDateAAR)} {formatPercent(record.purchaseDateAAR)}
@ -162,7 +193,7 @@ const columns: TableColumnsType<DataType> = [
key: 'retailerNameAAR', key: 'retailerNameAAR',
width: '130px', width: '130px',
render: (_, record) => { render: (_, record) => {
const isAbnormal = ensureMin(record.retailerNameAAR, 0.95); const isAbnormal = ensureMin(record.retailerNameAAR, 0.98);
return ( return (
<span style={{ color: isAbnormal ? 'red' : '' }}> <span style={{ color: isAbnormal ? 'red' : '' }}>
{formatPercent(record.retailerNameAAR)} {formatPercent(record.retailerNameAAR)}
@ -173,7 +204,7 @@ const columns: TableColumnsType<DataType> = [
], ],
}, },
{ {
title: 'Average Processing Time', title: 'Average Processing Per Image (Seconds)',
children: [ children: [
{ {
title: 'SN/IMEI', title: 'SN/IMEI',
@ -203,21 +234,6 @@ const columns: TableColumnsType<DataType> = [
}, },
], ],
}, },
{
title: 'Usage (Transaction Count)',
children: [
{
title: 'SN/IMEI',
dataIndex: 'snImeiTC',
key: 'snImeiTC',
},
{
title: 'Invoice',
dataIndex: 'invoiceTC',
key: 'invoiceTC',
},
],
},
]; ];
interface ReportOverViewTableProps { interface ReportOverViewTableProps {
@ -236,9 +252,9 @@ const ReportOverViewTable: React.FC<ReportOverViewTableProps> = ({
key: index, key: index,
subSidiaries: item.subs, subSidiaries: item.subs,
extractionDate: item.extraction_date, extractionDate: item.extraction_date,
totalImages: item.total_images,
snOrImeiNumber: item.num_imei, snOrImeiNumber: item.num_imei,
invoiceNumber: item.num_invoice, invoiceNumber: item.num_invoice,
totalImages: item.total_images,
successfulNumber: item.images_quality.successful, successfulNumber: item.images_quality.successful,
successfulPercentage: item.images_quality.successful_percent, successfulPercentage: item.images_quality.successful_percent,
badNumber: item.images_quality.bad, badNumber: item.images_quality.bad,
@ -263,7 +279,7 @@ const ReportOverViewTable: React.FC<ReportOverViewTableProps> = ({
bordered bordered
size='small' size='small'
scroll={{ x: 2000 }} scroll={{ x: 2000 }}
pagination={false} pagination={false}
/> />
</div> </div>
); );

View File

@ -1,3 +1,11 @@
.ant-table-thead > tr > th { .ant-table-thead > tr > th {
font-weight: 600 !important; font-weight: 600 !important;
} }
.sbt-table-wrapper .sbt-table-thead .hide-border-right {
border-right: none !important;
}
.sbt-table-wrapper .sbt-table-thead .show-border-left {
border-left: 1px solid #f0f0f0 !important;
}

View File

@ -1,29 +1,37 @@
export const formatPercent = (value: number) => { export const formatPercent = (value: number, floatingPoint: number = 1) => {
if (value === 0) { if (value === 0) {
return '-'; return '-';
} }
if (value < 100.0) { if (value < 100.0) {
value = value * 100; value = value * 100;
} }
return value.toFixed(2); return value.toFixed(floatingPoint);
} };
export const ensureMin = (value: number, min: number, skipZero: boolean = true) => { export const ensureMin = (
if (skipZero && value === 0) { value: number,
return false; min: number,
} skipZero: boolean = true,
if (value < min) { ) => {
return true; if (skipZero && value === 0) {
}
return false; return false;
} }
if (value < min) {
return true;
}
return false;
};
export const ensureMax = (value: number, max: number, skipZero: boolean = true) => { export const ensureMax = (
if (skipZero && value === 0) { value: number,
return false; max: number,
} skipZero: boolean = true,
if (value > max) { ) => {
return true; if (skipZero && value === 0) {
}
return false; return false;
} }
if (value > max) {
return true;
}
return false;
};