Files
frontend/apps/st/src/entities/statistics/model/input/statistics-sewage-supply-rate-input-interface.ts
T

218 lines
6.8 KiB
TypeScript

import type { ApiResponse, SewerageStatusInfo, StatisticsInputCommonInfoBase } from "../statistics-interface";
/** 검증 결과 한 건 (필드별 메시지) */
export interface VerificationResultItem {
vrfcCd: string;
rsnExpln: string;
nowVlCn: string;
compVlCn: string;
}
/** 필드명 → 검증 결과 배열. 예: { popltnSm: [{ type, rsn }], wstrPrmTrt: [...] } */
export type SewerageSupplyRateVerificationResult = Record<string, VerificationResultItem[]>;
// 하수도 보급률 데이터 항목
export interface SewerageSupplyRateCommonInfo extends StatisticsInputCommonInfoBase {
sewerBzmnArea: number;
sewerBzmnCd: string;
sewerBzmnFrgnrWholPpltnCnt: number;
sewerBzmnDomplWholPpltnCnt: number;
sewerBzmnWholPpltnCnt: number;
piplFcltyExtn: number;
piplPlanExtn: number;
ctpvNm: string;
statsYr: string;
statsCd: string;
/** 푸터(합계) 등 commonInfo 필드 검증 결과 */
verificationResult?: SewerageSupplyRateVerificationResult | null;
}
/** 하수도 보급률 목록 API 응답 한 행 (실제 응답 필드만) */
export interface SewerageSupplyRateItem {
admdstCd: string;
sggNm: string;
admdstNm: string;
rvbsn: string | null;
trbtrNm: string;
mdbsn: string;
lgbsn: string;
mdmbsn: string;
spcCtpnRgnCn: string | null;
totalPopl: number;
poplSm: number;
frgnrPoplSm: number;
refArea: number;
wholPpltnCnt: number;
wholArea: number;
wholSwtrmtPpltnCnt: number;
wholPblSwtrmtPpltnCnt: number;
ts1SwtrmtPpltnCnt: number;
ts2SwtrmtPpltnCnt: number;
ts3SwtrmtPpltnCnt: number;
wholWwtPrcsPpltnCnt: number;
ts1WwtPrcsPpltnCnt: number;
ts2WwtPrcsPpltnCnt: number;
ts3WwtPrcsPpltnCnt: number;
yetCntnPpltnCnt: number;
staaArea: number;
wholStaaExcpPpltnCnt: number;
unprcsPpltnCnt: number;
drtwPrcsPpltnCnt: number;
spctnkPpltnCnt: number;
staaExcpArea: number;
staaPsplyRt: number;
altdPrcsPsplyRt: number;
sewerInstlRt: number;
swagePplPsplyRt: number;
rmrk: string | null;
verificationResult?: SewerageSupplyRateVerificationResult | null;
}
export interface SewerageSupplyRateResponseData {
statusInfo: SewerageStatusInfo;
sewerageSupplyRateList: SewerageSupplyRateItem[];
commonInfo: SewerageSupplyRateCommonInfo;
}
export type SewerageSupplyRateApiResponse = ApiResponse<SewerageSupplyRateResponseData> & {
message: string;
}
export interface SewerageSupplyRateRequestParams {
ctpvNm?: string;
sggNm?: string;
sewerBzmnCd?: string;
statsYr?: string;
mode?: string;
}
/** 하수도 보급률 저장 API 요청 body (한 행) */
export interface SewerageSupplyRateSaveItem {
sggNm: string | null;
admdstCd: string | null;
admdstNm: string | null;
trbtrNm: string | null;
spcCtpnRgnCn: string | null;
ts1SwtrmtPpltnCnt: number;
ts2SwtrmtPpltnCnt: number;
ts3SwtrmtPpltnCnt: number;
ts1WwtPrcsPpltnCnt: number;
ts2WwtPrcsPpltnCnt: number;
ts3WwtPrcsPpltnCnt: number;
yetCntnPpltnCnt: number;
staaArea: number;
unprcsPpltnCnt: number;
drtwPrcsPpltnCnt: number;
spctnkPpltnCnt: number;
staaExcpArea: number;
rmrk: string | null;
wholPpltnCnt: number;
wholArea: number;
wholSwtrmtPpltnCnt: number;
wholPblSwtrmtPpltnCnt: number;
wholWwtPrcsPpltnCnt: number;
wholStaaExcpPpltnCnt: number;
staaPsplyRt: number;
altdPrcsPsplyRt: number;
sewerInstlRt: number;
}
export interface SewerageSupplyRateSaveRequest {
statsYr: string;
ctpvNm: string;
sggNm?: string;
sewerBzmnCd: string;
userId: string;
sewerBzmnArea?: number;
saveList?: SewerageSupplyRateSaveItem[];
submitList?: SewerageSupplyRateSaveItem[];
laePicNm?: string;
laeKbrdrJbgdNm?: string;
laeKbrdrDeptNm?: string;
laePicTelNo?: string;
laeIdfrNm?: string;
laeIdfrJbgdNm?: string;
laeIdfrDeptNm?: string;
laeIdfrTelNo?: string;
superAdmin?: string;
}
export interface SewerageSupplyRateSaveResponse {
data: string;
message?: string;
status: string;
}
export interface SewerageSupplyRateSubmitResponse {
data: {
finalStatus: string;
nvpassed: boolean;
isHbPassed?: string;
}
message?: string;
status: string;
}
// 하수도 통계 입력 기간 조회 (입력 INPT / 검증 VRFC 구간)
export interface CheckInputPeriodItem {
statsYr: string;
seCd: number;
seType: string;
bgngYmd: string;
endYmd: string;
current: boolean;
}
export interface CheckInputPeriodResponse {
status: string;
message: string;
data: CheckInputPeriodItem[];
}
/** 입력기간(INPT) 중 현재 구간이면 true */
export function isInputPeriodCurrent(periods: CheckInputPeriodItem[] | null | undefined): boolean {
return (periods ?? []).some((p) => p.seType === "INPT" && p.current === true);
}
/** `YYYYMMDD` → `yyyy-mm-dd` (그 외 형식은 그대로 반환) */
export function formatCheckInputYmdAsDash(ymd: string | null | undefined): string {
if (ymd == null || ymd === "") return "";
if (ymd.length === 8 && /^\d{8}$/.test(ymd)) {
return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;
}
return ymd;
}
/** 검증기간(VRFC) 중 `current`인 항목 (없으면 null) */
export function getCurrentVerificationPeriod(
periods: CheckInputPeriodItem[] | null | undefined,
): CheckInputPeriodItem | null {
return (periods ?? []).find((p) => p.seType === "VRFC" && p.current === true) ?? null;
}
/** 검증기간(VRFC) 중 현재 구간이면 true — 저장·제출·제출 취소 불가 */
export function isVerificationPeriodCurrent(periods: CheckInputPeriodItem[] | null | undefined): boolean {
return getCurrentVerificationPeriod(periods) !== null;
}
/**
* 검증기간이면 차단 안내 문구(줄바꿈 + yyyy-mm-dd ~ yyyy-mm-dd), 아니면 null
*/
export function getVerificationPeriodActionBlockedMessage(
periods: CheckInputPeriodItem[] | null | undefined,
): string | null {
const v = getCurrentVerificationPeriod(periods);
if (!v) return null;
const from = formatCheckInputYmdAsDash(v.bgngYmd);
const to = formatCheckInputYmdAsDash(v.endYmd);
const range =
from && to ? `${from} ~ ${to}` : [from, to].filter(Boolean).join(" ~ ");
return `검증기간에는 저장, 제출, 제출 취소를\n 할 수 없습니다.\n(검증기간: ${range})`;
}
export interface StatisticsInputSewSupplyRateService {
getSewerageSupplyRateList(params: SewerageSupplyRateRequestParams): Promise<SewerageSupplyRateApiResponse>;
checkInputPeriod(params: string): Promise<CheckInputPeriodResponse>;
saveSewerageSupplyRate(params: SewerageSupplyRateSaveRequest): Promise<SewerageSupplyRateSaveResponse>;
submitSewerageSupplyRate(params: SewerageSupplyRateSaveRequest): Promise<SewerageSupplyRateSubmitResponse>;
}