mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/hotfix/restu
This commit is contained in:
@@ -31,6 +31,11 @@ export const formatNumber = (
|
||||
}).format(value);
|
||||
};
|
||||
|
||||
export const safeRound = (num: number, decimals: number) => {
|
||||
const factor = 10 ** decimals;
|
||||
return Math.round((num + Number.EPSILON) * factor) / factor;
|
||||
};
|
||||
|
||||
export const formatTitleCase = (value: string) => {
|
||||
return value
|
||||
.toLowerCase()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as XLSX from 'xlsx';
|
||||
import toast from 'react-hot-toast';
|
||||
import { formatDate } from '@/lib/helper';
|
||||
import { formatDate, safeRound } from '@/lib/helper';
|
||||
import { isResponseSuccess } from '@/lib/api-helper';
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
@@ -32,21 +32,21 @@ export class ProductionResultReportApiService extends BaseApiService<
|
||||
const mappedProductionResults: {
|
||||
projectFlockKandang: BaseProjectFlockKandang;
|
||||
productionResult: ProductionResult[] | null;
|
||||
}[] = [];
|
||||
}[] = await Promise.all(
|
||||
(projectFlockKandangs || []).map(async (projectFlockKandang) => {
|
||||
const getProductionResultPath = `${this.basePath}/${projectFlockKandang.id}?page=1&limit=99999999`;
|
||||
const getProductionResultRes = await httpClient<
|
||||
BaseApiResponse<ProductionResult[]>
|
||||
>(getProductionResultPath);
|
||||
|
||||
projectFlockKandangs?.forEach(async (projectFlockKandang) => {
|
||||
const getProductionResultPath = `${this.basePath}/${projectFlockKandang.id}?page=1&limit=99999999`;
|
||||
const getProductionResultRes = await httpClient<
|
||||
BaseApiResponse<ProductionResult[]>
|
||||
>(getProductionResultPath);
|
||||
|
||||
mappedProductionResults.push({
|
||||
projectFlockKandang,
|
||||
productionResult: isResponseSuccess(getProductionResultRes)
|
||||
? getProductionResultRes.data
|
||||
: null,
|
||||
});
|
||||
});
|
||||
return {
|
||||
projectFlockKandang,
|
||||
productionResult: isResponseSuccess(getProductionResultRes)
|
||||
? getProductionResultRes.data
|
||||
: null,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
const rows = mappedProductionResults;
|
||||
if (!rows || rows.length === 0) {
|
||||
@@ -68,44 +68,46 @@ export class ProductionResultReportApiService extends BaseApiService<
|
||||
|
||||
row.productionResult?.forEach((productionResult) => {
|
||||
groupedData[kandangName].push({
|
||||
woa: productionResult.woa,
|
||||
bw: productionResult.bw,
|
||||
std_bw: productionResult.std_bw,
|
||||
uniformity: productionResult.uniformity,
|
||||
woa: safeRound(productionResult.woa, 2),
|
||||
bw: safeRound(productionResult.bw, 2),
|
||||
std_bw: safeRound(productionResult.std_bw, 2),
|
||||
uniformity: safeRound(productionResult.uniformity, 2),
|
||||
std_uniformity: productionResult.std_uniformity,
|
||||
dep_kum: productionResult.dep_kum,
|
||||
dep_std: productionResult.dep_std,
|
||||
butiran_utuh: productionResult.butiran_utuh,
|
||||
butiran_putih: productionResult.butiran_putih,
|
||||
butiran_retak: productionResult.butiran_retak,
|
||||
butiran_pecah: productionResult.butiran_pecah,
|
||||
butiran_jumlah: productionResult.butiran_jumlah,
|
||||
total_butir: productionResult.total_butir,
|
||||
kg_utuh: productionResult.kg_utuh,
|
||||
kg_putih: productionResult.kg_putih,
|
||||
kg_retak: productionResult.kg_retak,
|
||||
kg_pecah: productionResult.kg_pecah,
|
||||
kg_jumlah: productionResult.kg_jumlah,
|
||||
total_kg: productionResult.total_kg,
|
||||
persen_utuh: productionResult.persen_utuh,
|
||||
persen_putih: productionResult.persen_putih,
|
||||
persen_retak: productionResult.persen_retak,
|
||||
persen_pecah: productionResult.persen_pecah,
|
||||
hd: productionResult.hd,
|
||||
hd_std: productionResult.hd_std,
|
||||
fi: productionResult.fi,
|
||||
fi_std: productionResult.fi_std,
|
||||
em: productionResult.em,
|
||||
em_std: productionResult.em_std,
|
||||
ew: productionResult.ew,
|
||||
ew_std: productionResult.ew_std,
|
||||
fcr: productionResult.fcr,
|
||||
fcr_std: productionResult.fcr_std,
|
||||
hh: productionResult.hh,
|
||||
hh_std: productionResult.hh_std,
|
||||
project_flock_name: productionResult.project_flock.name,
|
||||
project_flock_category: productionResult.project_flock.category,
|
||||
kandang_name: productionResult.project_flock.kandang.name,
|
||||
dep_kum: safeRound(productionResult.dep_kum, 2),
|
||||
dep_std: safeRound(productionResult.dep_std, 2),
|
||||
butiran_utuh: safeRound(productionResult.butiran_utuh, 2),
|
||||
butiran_putih: safeRound(productionResult.butiran_putih, 2),
|
||||
butiran_retak: safeRound(productionResult.butiran_retak, 2),
|
||||
butiran_pecah: safeRound(productionResult.butiran_pecah, 2),
|
||||
butiran_jumlah: safeRound(productionResult.butiran_jumlah, 2),
|
||||
total_butir: safeRound(productionResult.total_butir, 2),
|
||||
kg_utuh: safeRound(productionResult.kg_utuh, 2),
|
||||
kg_putih: safeRound(productionResult.kg_putih, 2),
|
||||
kg_retak: safeRound(productionResult.kg_retak, 2),
|
||||
kg_pecah: safeRound(productionResult.kg_pecah, 2),
|
||||
kg_jumlah: safeRound(productionResult.kg_jumlah, 2),
|
||||
total_kg: safeRound(productionResult.total_kg, 2),
|
||||
persen_utuh: safeRound(productionResult.persen_utuh, 2),
|
||||
persen_putih: safeRound(productionResult.persen_putih, 2),
|
||||
persen_retak: safeRound(productionResult.persen_retak, 2),
|
||||
persen_pecah: safeRound(productionResult.persen_pecah, 2),
|
||||
hd: safeRound(productionResult.hd, 2),
|
||||
hd_std: safeRound(productionResult.hd_std, 2),
|
||||
fi: safeRound(productionResult.fi, 2),
|
||||
fi_std: safeRound(productionResult.fi_std, 2),
|
||||
em: safeRound(productionResult.em, 2),
|
||||
em_std: safeRound(productionResult.em_std, 2),
|
||||
ew: safeRound(productionResult.ew, 2),
|
||||
ew_std: safeRound(productionResult.ew_std, 2),
|
||||
fcr: safeRound(productionResult.fcr, 2),
|
||||
fcr_std: safeRound(productionResult.fcr_std, 2),
|
||||
hh: safeRound(productionResult.hh, 2),
|
||||
hh_std: safeRound(productionResult.hh_std, 2),
|
||||
project_flock_name:
|
||||
row.projectFlockKandang.project_flock.flock_name,
|
||||
project_flock_category:
|
||||
row.projectFlockKandang.project_flock.category,
|
||||
kandang_name: row.projectFlockKandang.kandang.name,
|
||||
created_at: formatDate(productionResult.created_at, 'YYYY-MM-DD'),
|
||||
updated_at: formatDate(productionResult.updated_at, 'YYYY-MM-DD'),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user