Files
frontend/apps/sn/app/components/lib/utils/excelToJson.ts
T

63 lines
1.9 KiB
TypeScript

export const TEST_UUID= '2d4b151d-1828-41e0-91d9-4cd28ea1cc7e'
import { z } from "zod";
// 수용가-맨홀 매칭결과 (아직 안함)
export const MatchingResultZod = z.object({
anls_sn: z.number(),
mhl_mng_no: z.string(), // 일련번호 0 포함인지? number? string?
rcptr_no: z.string(),
});
export type MatchingResultZodType = z.infer<typeof MatchingResultZod>;
export const excelToMatchingResultData = (excelData: any) => {
const MatchingResultData: MatchingResultZodType[] = excelData.map((item: any) => {
return {
anls_sn: Number(item["NO"]),
mhl_mng_no: String(item["FTR_IDN"]), // 임시값이라 추후 수정 필요
rcptr_no: String(item["수용가"]),
};
}).filter((el: any) => el !== undefined);
return MatchingResultData;
};
// 시간패턴
export const timePatternZod = z.object({
hr_id: z.number(),
rt: z.number().nullish(),
});
export type timePatternZodType = z.infer<typeof timePatternZod>;
export const excelToTimePatternData = (excelData: any) => {
const timePatternData: timePatternZodType[] = excelData.map((item: any) => {
return {
hr_id: Number(item["시간"]),
rt: Number(item["비율"]),
};
}).filter((el: any) => el !== undefined);
return timePatternData;
};
// 유량자료
export const flowRateZod = z.object({
ppl_mng_no: z.string(),
mtrng_dt: z.number(), // type 뭘로 해야할지 Date? timeStamp임
oilq: z.number().nullish(),
});
export type flowRateZodType = z.infer<typeof flowRateZod>;
export const excelToflowRateData = (excelData: any) => {
const flowRateData: flowRateZodType[] = excelData.map((item: any) => {
return {
ppl_mng_no: String(item["관로번호"]),
mtrng_dt: new Date(item["시간"]).toISOString(), // type 뭘로 해야할지 Date? timeStamp임
oilq: Number(item["유량(㎥/h)"]),
};
}).filter((el: any) => el !== undefined);
return flowRateData;
};