[st] - feat: 입력 04 작업 중 & 수정 요청 사항 적용
This commit is contained in:
@@ -179,6 +179,29 @@ export function createSwrgInstlrtRateValueCallback(
|
||||
};
|
||||
}
|
||||
|
||||
/** 총양수량: Σ(펌프대수 + 예비펌프대수) × 대당 양수량 */
|
||||
export function createPumpGrossPpqtyValueCallback(
|
||||
pumpGroups: Array<{
|
||||
pumpCntField: string;
|
||||
rsrvPumpCntField: string;
|
||||
perPpqtyField: string;
|
||||
}>,
|
||||
): DataFieldValueCallback {
|
||||
return (_prod, _dataRow, _fieldName, fieldNamesArr, values) => {
|
||||
let total = 0;
|
||||
for (const group of pumpGroups) {
|
||||
const pumpIdx = fieldNamesArr.indexOf(group.pumpCntField);
|
||||
const rsrvIdx = fieldNamesArr.indexOf(group.rsrvPumpCntField);
|
||||
const perIdx = fieldNamesArr.indexOf(group.perPpqtyField);
|
||||
const pumpCnt = pumpIdx >= 0 ? toNum(values[pumpIdx]) : 0;
|
||||
const rsrvCnt = rsrvIdx >= 0 ? toNum(values[rsrvIdx]) : 0;
|
||||
const perPpqty = perIdx >= 0 ? toNum(values[perIdx]) : 0;
|
||||
total += (pumpCnt + rsrvCnt) * perPpqty;
|
||||
}
|
||||
return total;
|
||||
};
|
||||
}
|
||||
|
||||
/** 연산 타입에 맞는 valueCallback 반환 */
|
||||
export function getComputedValueCallback(config: ComputedFieldConfig): DataFieldValueCallback {
|
||||
switch (config.type) {
|
||||
@@ -209,5 +232,7 @@ export function getComputedValueCallback(config: ComputedFieldConfig): DataField
|
||||
return createCoverageRateValueCallback(config.numeratorFields, config.denominatorFields);
|
||||
case 'swrgInstlrtRate':
|
||||
return createSwrgInstlrtRateValueCallback(config.numeratorFields, config.denominatorFields, config.thirdFields);
|
||||
case 'pumpGrossPpqty':
|
||||
return createPumpGrossPpqtyValueCallback(config.pumpGroups);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,61 @@ export function formatCompactYmdForGrid(ymd: string | number | null | undefined)
|
||||
return `${s.slice(0, 4)}-${s.slice(4, 6)}-${s.slice(6, 8)}`;
|
||||
}
|
||||
|
||||
/** 그리드 값 → API 8자리 일자(yyyyMMdd) */
|
||||
export function toCompactYmd(value: string | number | null | undefined): string {
|
||||
const s = String(value ?? "").replace(/\D/g, "");
|
||||
if (s.length !== 8) return "";
|
||||
return s;
|
||||
function isValidCompactYmdDigits(ymd: string): boolean {
|
||||
if (!/^\d{8}$/.test(ymd)) return false;
|
||||
const y = Number(ymd.slice(0, 4));
|
||||
const m = Number(ymd.slice(4, 6));
|
||||
const d = Number(ymd.slice(6, 8));
|
||||
if (y < 1000 || y > 9999 || m < 1 || m > 12 || d < 1 || d > 31) return false;
|
||||
const dt = new Date(y, m - 1, d);
|
||||
return dt.getFullYear() === y && dt.getMonth() === m - 1 && dt.getDate() === d;
|
||||
}
|
||||
|
||||
function formatDateToCompactYmd(date: Date): string {
|
||||
if (Number.isNaN(date.getTime())) return "";
|
||||
const y = date.getFullYear();
|
||||
const m = date.getMonth() + 1;
|
||||
const d = date.getDate();
|
||||
if (y < 1000 || y > 9999) return "";
|
||||
return `${y}${String(m).padStart(2, "0")}${String(d).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 그리드·API 값 → 8자리 일자(yyyyMMdd).
|
||||
* RealGrid datetime은 Date 객체로 올 수 있어, 숫자만 이어붙이는 방식은 사용하지 않습니다.
|
||||
*/
|
||||
export function toCompactYmd(
|
||||
value: string | number | Date | null | undefined,
|
||||
): string {
|
||||
if (value == null || value === "") return "";
|
||||
|
||||
if (value instanceof Date) {
|
||||
return formatDateToCompactYmd(value);
|
||||
}
|
||||
|
||||
if (typeof value === "number" && Number.isFinite(value)) {
|
||||
if (value >= 19000101 && value <= 21001231) {
|
||||
const compact = String(Math.trunc(value)).padStart(8, "0").slice(-8);
|
||||
return isValidCompactYmdDigits(compact) ? compact : "";
|
||||
}
|
||||
if (value > 1e11) {
|
||||
return formatDateToCompactYmd(new Date(value));
|
||||
}
|
||||
}
|
||||
|
||||
const trimmed = String(value).trim();
|
||||
const isoLike = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
||||
if (isoLike) {
|
||||
const compact = `${isoLike[1]}${isoLike[2]}${isoLike[3]}`;
|
||||
return isValidCompactYmdDigits(compact) ? compact : "";
|
||||
}
|
||||
|
||||
const digits = trimmed.replace(/\D/g, "");
|
||||
if (digits.length === 8 && isValidCompactYmdDigits(digits)) {
|
||||
return digits;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/** 설치목적 등 O/X 표기 → 대문자 O 또는 X (그 외는 원문 유지) */
|
||||
|
||||
Reference in New Issue
Block a user