-
-
-
+
+ {/* 시설 등록 */}
+
+
시설 등록
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ {/* 지도점검 결과 */}
+
+
지도점검 결과
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 시설 현황 */}
+
+
시설 현황
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 수요처 관리 */}
+
+
수요처 관리
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 수요처 매칭 */}
+
+
수요처 매칭
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 통계*/}
+
+
통계 매칭
+
+
+
+
+
+
+
+
+
+
+
+
- >
+ >
);
}
diff --git a/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/publicReuseFaciltyInsert/page.tsx b/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/publicReuseFaciltyInsert/page.tsx
deleted file mode 100644
index 57c48a84d..000000000
--- a/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/publicReuseFaciltyInsert/page.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-'use client'
-
-import { ScrollArea, SearchDiv, SelectBox, UiTable } from '@common/business_components';
-import { Button } from '@common/components';
-import { PublicReuseFaciltyFormInsert } from '../../../../components/ui/publicReuseInsertForm';
-import { useWrStore } from '../../../store';
-
-
-
- export default function PublicReuseFaciltyInsert() {
- const {pubFac} = useWrStore((state) => state);
- const { pubFacHeadList, publicReuseFacilityData} = pubFac;
- const searchDiv = '하수재이용시설 '
- const selectBox = [{ text: '서울하수처리시설', val: "1_hasu" }, { text: '서울1하수처리시설', val: "2_hasu" }, { text: '서울2하수처리시설', val: "3_hasu" }]
- const headName = () => {
- return (
-
○공공 하수처리시설 등록
- )
- }
- const onSelectValue = (val: string) => {
- console.log(val)
- }
- return (
- <>
-
-
-
하수재이용시설 등록
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- )
-}
diff --git a/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/rainReuseFaciltyInsert/page.tsx b/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/rainReuseFaciltyInsert/page.tsx
deleted file mode 100644
index c94a93075..000000000
--- a/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/rainReuseFaciltyInsert/page.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-'use client'
-import { useWrStore } from "@/app/store";
-import type { TableUpperProps } from "@/app/store/rainReuseFacilityInsert"
-import { RainReuseFaciltyInsertForm } from "@/components/ui/rainReuseInsertForm";
-import { ScrollArea, SearchDiv, SearchInput, UiTable } from "@common/business_components";
-import { Button, TableHead, TableRow } from "@common/components";
-
-
-export const headMakeColSpan = (upHeadList: TableUpperProps[]) => {
- return (<>
-
{
- upHeadList.map((head: TableUpperProps) =>
- (!head.upSequnce ? {head.title} :
- head.upName === 'upChangeRe' && head.upSequnce === 1 ? {'중축 개축 증축 '} : null))}
-
-
- {upHeadList.map((head: TableUpperProps) =>
- (head.upName === 'upChangeRe' ? {head.title} : null))}
-
- >)
-}
-
-
-export default function Home() {
- const { rain } = useWrStore((state) => state);
- const nodeList = headMakeColSpan(rain.upHeadList);
-
-
- const headName = () => {
- return (
-
○건축물 목록
- )
- }
- return (
- <>
-
-
-
빗물이용시설 등록
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {nodeList}
-
-
-
-
-
-
-
-
-
- >
- );
-}
diff --git a/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/rswtReuseFacilityInsert/page.tsx b/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/rswtReuseFacilityInsert/page.tsx
deleted file mode 100644
index cecd4177c..000000000
--- a/apps/wr/app/reuseFaciltyManage/reuseFacilityInsert/rswtReuseFacilityInsert/page.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-'use client'
-import { useWrStore } from "@/app/store";
-import type { TableUpperProps } from "@/app/store/rainReuseFacilityInsert";
-import { RswtrReuseFaciltyInsertForm } from "@/components/ui/rswtrReuseInsetForm";
-import { ScrollArea, SearchDiv, SearchInput, UiTable } from "@common/business_components";
-import { Button, TableHead, TableRow } from "@common/components";
-
-
-const headMakeColSpan = (upHeadList: TableUpperProps[]) => {
- return (<>
-
{
- upHeadList.map((head: TableUpperProps) =>
- (!head.upSequnce ? {head.title} :
- head.upName === 'upChangeRe' && head.upSequnce === 1 ? {'중축 개축 증축 '} : null))}
-
-
- {upHeadList.map((head: TableUpperProps) =>
- (head.upName === 'upChangeRe' ? {head.title} : null))}
-
- >)
-}
-
-
-export default function Home() {
- const {rswt} = useWrStore((state) => state);
- const nodeList = headMakeColSpan(rswt.upHeadList);
- const total = 100;
-
-
- const headName = () => {
- return (
-
○건축물 목록
- )
- }
-
- return (
- <>
-
-
-
중수도시설 등록
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {nodeList}
-
-
-
-
-
-
-
-
-
- >
- );
-}
diff --git a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx
new file mode 100644
index 000000000..8227e0347
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx
@@ -0,0 +1,167 @@
+"use client";
+
+import { useWrStore } from "@/app/store";
+import {
+ ContentsDiv,
+ ScrollArea,
+ SearchDiv,
+ SearchFormLeft,
+ SearchFormRight,
+ SearchInput,
+ Title,
+ UiModal,
+ UiTable,
+} from "@common/business_components";
+import { Button } from "@common/components";
+import ListDiv from "@common/business_components/ui/list_div";
+import { useEffect, useState } from "react";
+import { tableData } from "@/components/lib/func/commom";
+import HtdflRegForm from "@/components/ui/form/fcltReg/htdflReg/htdflRegForm";
+import type { chgBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
+import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
+import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
+
+export default function Home() {
+ const { code, htdfl, initHtdfl,getHtdflBdstData } = useWrStore((state) => state);
+ const [searchTxt, setSearchTxt] = useState("");
+ const [pageNation, setPageNation] = useState(1);
+
+ const [htdflForm, setHtdflForm] = useState
();
+ const [bdstTable, setbdstTable] = useState();
+ const [issNewReg,setIsNewReg] = useState( false);
+
+ const [bdstChgProps, setBdstChgProps] = useState<{
+ isOpen: boolean;
+ chgBuilding: chgBuilding[];
+ }>({ isOpen: false, chgBuilding: [] });
+
+ const { htdflRes } = htdfl;
+
+ useEffect(() => {
+ if (!htdfl.isInit) {
+ initHtdfl('0');
+ }
+ }, [htdfl.isInit, initHtdfl]);
+
+ useEffect(() => {
+ if (code.sggCd.length > 0) {
+
+ const htdflData = tableData(htdflRes, { code }).map(
+ (item: customHtdflBdst) => {
+ return {
+ ...item,
+ bdstChgYn: item?.chgBuilding && item.chgBuilding.length > 0 && item.chgBuilding[0]?.bdstChgNm !== null ? 'Y' : 'N',
+ bdstUsgCd: item.reuseBuilding[0]?.bdstUsgCd
+ };
+ }
+ );
+ setbdstTable(htdflData);
+ }
+ }, [code, htdflRes]);
+
+ const cellClick: (val: number|undefined ,headId: string) => void = (
+ val
+ ,headId) => {
+ if ((bdstTable ?? []).length > 0 && val !== undefined) {
+ {
+ setHtdflForm(htdflRes[val]);
+ }
+ }
+
+ if (headId === "bdstChgYn" && val !== undefined) {
+ if (
+ htdflRes[val]?.bdstInfoPk != null &&
+ htdflRes[val]?.chgBuilding?.length > 0
+ ) {
+ bdstChgModal(htdflRes[val]?.chgBuilding as chgBuilding[]);
+ }
+ }
+ };
+ const bdstChgModal = (chgBuilding: chgBuilding[]) => {
+ setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding });
+ };
+ useEffect(() => {
+ getHtdflBdstData(pageNation, "0");
+ }, [pageNation]);
+
+ return (
+ <>
+
+
+
+
+
+
+ {
+ setSearchTxt(e);
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { cellClick(val || undefined, headId); } }
+ onPageChange={setPageNation}
+ >
+
+
+
+
+
+
+
+
+
+
+
+ }
+ bodyClass="w-[68vw] max-w-none h-[90vh]"
+ open={issNewReg}
+ onOpenChange={(open) => {
+ setIsNewReg(open);
+ }}
+ />
+
+ }
+ onOpenChange={(open) => {
+ setBdstChgProps({ ...bdstChgProps, isOpen: open });
+ }
+ }
+ />
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx
new file mode 100644
index 000000000..441eabf25
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx
@@ -0,0 +1,329 @@
+"use client";
+import {
+ ContentsDiv,
+ ScrollArea,
+ SearchDiv,
+ SearchFormLeft,
+ SearchInput,
+ Title,
+ UiModal,
+ UiTable,
+} from "@common/business_components";
+import { Button } from "@common/components";
+import { useWrStore } from "../../../store";
+import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components";
+import { useCallback, useEffect, useState } from "react";
+import ListDiv from "@common/business_components/ui/list_div";
+import { tableData } from "@/components/lib/func/commom";
+import type {
+ customPbnst,
+ fcBizType,
+ PbnstRegArrrayType,
+ pubHasuType,
+} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
+import {
+ pbnstRegZod,
+ pbnstRegArrayZod,
+ fcBizSchema,
+} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
+import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm";
+import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm";
+import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal";
+import toast, { Toaster } from "react-hot-toast";
+import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg";
+import { useFieldArray, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+export default function PublicReuseFaciltyInsert() {
+ const {
+ code,
+ pbnst,
+ searchFclts,
+ pubHasuInit,
+ pbnstRegClick,
+ pbnstRuseFcltUpdate,
+ pubHasuSearch,
+ pbnstRuseBizUpdate,
+ } = useWrStore((state) => state);
+ const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst;
+ const [currentTab, setCurrentTab] = useState("mng");
+ const [isRuseReg, setIsRuseReg] = useState<{
+ isModal: boolean;
+ data: pubHasuType;
+ }>({ isModal: false, data: {} as pubHasuType });
+
+ const [indexMng, setIndexMng] = useState(0);
+ const [indexBiz, setIndexBiz] = useState(0);
+ const [searchTxt, setSearchTxt] = useState();
+ const [bdstTable, setbdstTable] = useState();
+ const [selectRow, setSelectRow] = useState();
+ const [pageNation, setPageNation] = useState(1);
+
+
+ const form = useForm<{
+ items: z.infer[];
+ }>({
+ resolver: zodResolver(z.object({ items: pbnstRegArrayZod })),
+ // defaultValues: { items: pbnstRegArrayZod.parse([]) },
+ mode: "onChange",
+ });
+ const {
+ fields: items,
+ append,
+ remove,
+ } = useFieldArray({
+ control: form.control,
+ name: `items`,
+ });
+ useEffect(() => {
+ if (!pbnst.isInit) {
+ pubHasuInit("1", "41");
+ }
+ }, [pbnst.isInit, pubHasuInit]);
+
+ const onSubmit = async (valuse: { items: PbnstRegArrrayType }) => {
+ const data = writeRgtrAndMdfr(valuse.items);
+ let bizs = [] as fcBizType[];
+ data.forEach((fclt) => {
+ bizs = [...bizs, ...fclt.fcBizs];
+ });
+ const pbnst =data.map((fclt) => {
+ return({
+ pbnstRuseFcltPk: fclt.pbnstRuseFcltPk,
+ fcltCpct: fclt.fcltCpct,
+ ruseCpct: fclt.ruseCpct,
+ splyExtraCpct: fclt.splyExtraCpct,
+ rgtr: fclt.rgtr,
+ mdfr: fclt.mdfr,
+ fcFiles: fclt.fcFiles,
+ fcOpers: fclt.fcOpers,
+ })
+ })
+ await pbnstRuseFcltUpdate(pbnst as customPbnst[]);
+
+ await pbnstRuseBizUpdate(bizs);
+ };
+
+ useEffect(() => {
+ if (code.sggCd.length) {
+ if (searchFclts) {
+ setbdstTable(tableData(searchFclts, { code }));
+ } else if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) {
+ setbdstTable(tableData(pbnstHasuRes, { code }));
+ }
+ }
+ }, [code, pbnstHasuRes, searchFclts]);
+
+ const cellClick = (val: number | undefined) => {
+ if (val === undefined) return;
+ const selectRow = pbnstHasuRes?.[val];
+ setSelectRow(pbnstHasuRes?.[val]);
+ if (selectRow) {
+ pbnstRegClick(selectRow);
+ }
+ };
+
+ const handleTabChange = (value: string) => {
+ setCurrentTab(value);
+ };
+
+ useEffect(() => {
+ if (pbnst.pbnstRes&& pbnst.pbnstRes?.length>0) {
+ console.log("pbnst.pbnstRes", pbnstRes);
+ form.reset({ items: pbnstRegArrayZod.parse(pbnst.pbnstRes) });
+ }else{
+
+ console.log("pbnst.pbnstRes is null", pbnstRes);
+ form.reset({ items: [] });
+ }
+ }, [pbnst.pbnstRes]);
+ useEffect(() => {
+ if (indexMng) {
+ setIndexBiz(0);
+ }
+ }, [indexMng]);
+
+ useEffect(() => {
+ console.log("form errors:", form.formState.errors);
+ }, [form.formState.errors]);
+
+ const appendPbnstRuseFclt = useCallback(() => {
+ const selecTableRow = selectRow;
+
+ if (pbnstRes && pbnstRes.length > 0) {
+ const lastPbnst = pbnstRes[pbnstRes.length - 1];
+ if (lastPbnst && selecTableRow) {
+
+ append(
+ pbnstRegZod.parse({
+ pbnstRuseFcltPk:
+ String(selecTableRow.bscFctCd) + String(pbnstRes.length + 1),
+ ruseUtztnFcltNm: "",
+ fcBizs: [
+ fcBizSchema.parse({
+ pbnstRuseFcltFk:
+ String(lastPbnst.pbnstRuseFcltPk) +
+ String(pbnstRes.length + 1),
+ cycl: 1,
+ }),
+ ] as fcBizType[],
+ })
+ );
+ setIsRuseReg({ ...isRuseReg, isModal: true });
+ }
+ } else {
+ if (selecTableRow) {
+ append(
+ pbnstRegZod.parse({
+ pbnstRuseFcltPk: String(selecTableRow.bscFctCd)+'1',
+ ruseUtztnFcltNm: "",
+ regDt: null,
+ mdfcnDt: null,
+ fcBizs: [fcBizSchema.parse({pbnstRuseFcltFk:String(selecTableRow.bscFctCd)+'1',cycl:1})] as fcBizType[],
+ })
+ )
+ setIsRuseReg({ ...isRuseReg, isModal: true });
+ }
+ }
+ }, [pbnstRegZod, pbnstRes, append, selectRow, form]);
+
+ useEffect(() => {
+ // console.log(" page getgetvaslue ", form.getValues());
+ }, [form.getValues()]);
+
+useEffect(() =>{
+ pubHasuInit(String(pageNation), "41");
+},[pageNation,pubHasuInit])
+
+ return (
+ <>
+
+
+
+
+
+
+ {
+ setSearchTxt(e);
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 시설정보
+
+
+ 차수별정보
+
+
+
+
+ {
+ console.log("setIndexMng", index);
+ setIndexMng(index);
+ }}
+ indexMng={indexMng}
+ />
+
+
+ {
+ setIndexBiz(index);
+ }}
+ indexMng={indexMng}
+ indexBiz={indexBiz}
+ />
+
+
+
+
+
+ }
+ bodyClass="w-[68vw] max-w-none h-[90vh]"
+ open={isRuseReg.isModal}
+ onOpenChange={(open) => {
+ remove(form.getValues("items").length - 1);
+ setIsRuseReg({ data: {} as pubHasuType, isModal: open });
+ }}
+ />
+
+
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/TableHead.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/TableHead.tsx
new file mode 100644
index 000000000..9dd67dc44
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/TableHead.tsx
@@ -0,0 +1,30 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import { TableRow, TableHead } from "@common/components/ui";
+
+export const makeFcltRegHead = (upHeadList: TableUpperProps[]) => {
+ return (
+ <>
+
+ {upHeadList.map((head: TableUpperProps) =>
+ !head.upSequnce ? (
+
+ {head.title}
+
+ ) : head.upName === "upChangeRe" && head.upSequnce === 1 ? (
+
+ {"중축 개축 재축 "}
+
+ ) : null
+ )}
+
+
+ {upHeadList.map((head: TableUpperProps) =>
+ head.upName === "upChangeRe" ? (
+ {head.title}
+ ) : null
+ )}
+
+ >
+ );
+ };
+
\ No newline at end of file
diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx
new file mode 100644
index 000000000..31743aaa9
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx
@@ -0,0 +1,181 @@
+"use client";
+import { useWrStore } from "@/app/store";
+import {
+ type chgBuilding,
+ type customRainBdst,
+} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import { tableData } from "@/components/lib/func/commom";
+import RainRegForm from "@/components/ui/form/fcltReg/rainReg/rainRegForm";
+import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
+import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
+import {
+ ContentsDiv,
+ ScrollArea,
+ SearchDiv,
+ SearchFormLeft,
+ SearchInput,
+ Title,
+ UiModal,
+ UiTable,
+} from "@common/business_components";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button } from "@common/components";
+import { useEffect, useState } from "react";
+
+export default function Home() {
+ const { rain, code, initRain, rainSearch, getRainData } = useWrStore((state) => {
+ return state;
+ });
+ const { rainRes } = rain;
+ const [rainForm, setRainForm] = useState();
+ const [issNewReg, setIsNewReg] = useState(false);
+ const [pageNation, setPageNation] = useState(1);
+ const [bdstTable, setbdstTable] = useState();
+ const [searchTxt, setSearchTxt] = useState();
+ const [bdstChgProps, setBdstChgProps] = useState<{
+ isOpen: boolean;
+ chgBuilding: chgBuilding[];
+ }>({ isOpen: false, chgBuilding: [] });
+
+ useEffect(() => {
+ if (!rain.isInit) {
+ initRain('41');
+ }
+ }, [rain.isInit, initRain]);
+
+ useEffect(() => {
+ if (code.sggCd.length > 0) {
+ const rainData = tableData(rainRes, { code }).map(
+ (item: customRainBdst) => {
+ return {
+ ...item,
+ bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N",
+ };
+ }
+ );
+
+ setbdstTable(rainData);
+ }
+ }, [code, rainRes]);
+ const cellClick: (val: number | undefined, headId: string) => void = (
+ val,
+ headId
+ ) => {
+ if (val !== undefined) {
+ setRainForm(rainRes[val]);
+ }
+
+ if (headId === "bdstChgYn" && val !== undefined) {
+ if (
+ rainRes[val]?.bdstInfoPk != null &&
+ rainRes[val]?.chgBuilding.length > 0
+ ) {
+ bdstChgModal(rainRes[val].chgBuilding);
+ }
+ }
+ };
+
+ const bdstChgModal = (chgBuilding: chgBuilding[]) => {
+ setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding });
+ };
+
+ useEffect(() => {
+ console.log("getPageNation", pageNation);
+ getRainData(pageNation, "41");
+ }, [pageNation]);
+
+ return (
+ <>
+
+
+
+
+
+
+ {
+ setSearchTxt(e);
+ }}
+ />
+
+
+
+
+
+ {/*
+
+ */}
+
+
+
+
+
+
+ {/* */}
+ {
+ cellClick(val, headId);
+ }}
+ onPageChange={setPageNation}
+ >
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+ }
+ bodyClass="w-[68vw] max-w-none h-[90vh]"
+ open={issNewReg}
+ onOpenChange={(open) => {
+ setIsNewReg(open);
+ }}
+ />
+
+
+ }
+ onOpenChange={(open) => {
+ setBdstChgProps({ ...bdstChgProps, isOpen: open });
+ }}
+ />
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx
new file mode 100644
index 000000000..2931690b9
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx
@@ -0,0 +1,174 @@
+"use client";
+import { useWrStore } from "@/app/store";
+import type { chgBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
+import { tableData } from "@/components/lib/func/commom";
+import RswtrRegForm from "@/components/ui/form/fcltReg/rswtrReg/rswtrRegForm";
+import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
+import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
+import {
+ ContentsDiv,
+ ScrollArea,
+ SearchDiv,
+ SearchFormLeft,
+ SearchFormRight,
+ SearchInput,
+ Title,
+ UiModal,
+ UiTable,
+} from "@common/business_components";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button } from "@common/components";
+import { useEffect, useState } from "react";
+
+export default function Home() {
+ const { code, rswt, initRswt, rswtBdstSearch, getRswtBdstData } = useWrStore(
+ (state) => state
+ );
+ const [rswtForm, setRswtForm] = useState();
+ const [searchTxt, setSearchTxt] = useState();
+ const [issNewReg, setIsNewReg] = useState(false);
+ const [pageNation, setPageNation] = useState(1);
+ const [selectVal, setSelect] = useState();
+ const [bdstTable, setbdstTable] = useState();
+ const [bdstChgProps, setBdstChgProps] = useState<{
+ isOpen: boolean;
+ chgBuilding: chgBuilding[];
+ }>({ isOpen: false, chgBuilding: [] });
+ const { rswtRes } = rswt;
+ useEffect(() => {
+ if (!rswt.isInit) {
+ initRswt("41");
+ }
+ }, [rswt.isInit, initRswt]);
+ useEffect(() => {
+ if (code.sggCd.length > 0) {
+ const rswtData = tableData(rswtRes, { code }).map(
+ (item: customRswtBdst) => {
+ return {
+ ...item,
+ bdstChgYn: item.chgBuilding[0]?.bdstChgNm != null ? "Y" : "N",
+ bdstUsgCd: item.reuseBuilding[0]?.bdstUsgCd,
+ };
+ }
+ );
+ setbdstTable(rswtData);
+ setRswtForm(rswtRes[selectVal ?? 0]);
+ }
+ }, [code, rswtRes, selectVal]);
+ const cellClick: (val: number | undefined, headId: string) => void = (
+ val,
+ headId
+ ) => {
+ if ((bdstTable ?? []).length > 0 && val !== undefined) {
+ {
+ setSelect(val);
+ setRswtForm(rswtRes[val]);
+ }
+ }
+
+ if (headId === "bdstChgYn" && val !== undefined) {
+ if (
+ rswtRes[val]?.bdstInfoPk != null &&
+ rswtRes[val]?.chgBuilding?.length > 0
+ ) {
+ bdstChgModal(rswtRes[val].chgBuilding);
+ }
+ }
+ };
+ const bdstChgModal = (chgBuilding: chgBuilding[]) => {
+ setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding });
+ };
+ useEffect(() => {
+ getRswtBdstData(pageNation, "41");
+ }, [pageNation]);
+
+ return (
+ <>
+
+
+
+
+
+
+ {
+ setSearchTxt(e);
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+ bodyClass="w-[68vw] max-w-none h-[90vh]"
+ open={issNewReg}
+ onOpenChange={(open) => {
+ setIsNewReg(open);
+ }}
+ />
+
+ }
+ onOpenChange={(open) => {
+ setBdstChgProps({ ...bdstChgProps, isOpen: open });
+ }}
+ />
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx
new file mode 100644
index 000000000..e43d5b04f
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx
@@ -0,0 +1,193 @@
+"use client";
+
+import { useWrStore } from "@/app/store";
+import { btnClass } from "@/app/store/common/code";
+import type {
+ chgBuilding,
+ customRainBdst,
+} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import {
+ excelDownload,
+ getCityOrSgg,
+ tableData,
+} from "@/components/lib/func/commom";
+import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal";
+import SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal";
+import {
+ ContentsDiv,
+ SearchBaseForm,
+ Title,
+ UiModal,
+ UiTable,
+ type ReturnType,
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button } from "@common/components/ui";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { excelHtdflSttnParsing } from "@/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel";
+import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
+
+export default function HtdflSttn() {
+ const { code, htdflSttn, htdflSttnSearch, initHtdfl } = useWrStore(
+ (state) => state
+ );
+ const { htdflSttnRes } = htdflSttn;
+
+ const ref = useRef({} as ReturnType);
+
+ const [pageNation, setPageNation] = useState(1);
+ const [isChHead, setIsChHead] = useState(false);
+ const [bdstTable, setBdstTable] = useState();
+ const [detailModal, setDetailModal] = useState<{
+ isOpen: boolean;
+ data: customRainBdst | undefined;
+ }>({ data: undefined, isOpen: false });
+ const [bdstChgProps, setBdstChgProps] = useState<{
+ isOpen: boolean;
+ chBuilding: chgBuilding[];
+ }>({ isOpen: false, chBuilding: [] });
+
+ const codeData = getCityOrSgg(ref);
+
+ const excelClick = useCallback(() => {
+ if (codeData) htdflSttnSearch(1, "10000", codeData);
+ }, [htdflSttnSearch, codeData]);
+
+ useEffect(() => {
+ if (codeData != null) htdflSttnSearch(pageNation, "20", codeData);
+ }, [pageNation]);
+
+ const cellClick = (index: number | undefined, headId: string) => {
+ if (
+ headId !== "chBuildingYn" &&
+ index !== undefined &&
+ bdstTable !== undefined
+ ) {
+ setDetailModal({ isOpen: true, data: bdstTable[index] });
+ }
+ };
+ useEffect(() => {
+ const excelDown = async () => {
+ if (htdflSttn.excelList.length > 0) {
+ if (htdflSttn.excelList.length === 0) return;
+ const excelData = await tableData(htdflSttn.excelList, { code });
+ const htdflExcel = excelHtdflSttnParsing(excelData, code.cityCd, code.sggCd);
+ excelDownload(
+ htdflExcel as [[]],
+ "온배수시설 현황",
+ "sample_htdflSttn.xlsx",
+ "A1:S3"
+ );
+ }
+ };
+ excelDown();
+ }, [htdflSttn.excelList, code]);
+
+ useEffect(() => {
+ if (!htdflSttn.isInit) {
+ initHtdfl(codeData ?? "0");
+ }
+ }, [htdflSttn.isInit, initHtdfl]);
+
+ useEffect(() => {
+ if (htdflSttnRes.length > 0 && code.cityCd.length > 0) {
+ const data = tableData(htdflSttnRes, { code });
+ const chData = data
+ .map((item: any) => ({
+ ...item,
+ ...item.reuseBuilding[0],
+ ...item.reuseBuilding[0].htdflObj,
+ chBuildingYn: item.chgBuilding[0]?.bdstChgNm !== null ? "Y" : "N",
+ }))
+ .filter((item: any) => item.htdflObj !== undefined);
+
+ setBdstTable(chData);
+ }
+ }, [code, htdflSttnRes, htdflSttn.htdflSttHeadList]);
+
+ return (
+ <>
+
+
+
+
+ {
+ setIsChHead(true);
+ } }
+ >
+ 조회항목설정
+ }
+ leftChildren={undefined}
+ queryClick={function (returnType: ReturnType): void {
+ // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}'
+ let con;
+ if (returnType.sigunValue != "0") {
+ con = returnType.sigunValue;
+ } else {
+ con = returnType.sidoValue;
+ }
+ htdflSttnSearch(pageNation, "20", con);
+ } }
+ excelClick={excelClick}
+ initClick={function (): void { } }
+ btnClass={btnClass}
+ ref={ref} isAdmin={false} />
+
+
+
+
+
+
+ }
+ headlist={htdflSttn.htdflSttHeadList}
+ pageSize={20}
+ total={100000}
+ cellClick={(index: number | undefined, headId: string) => {
+ cellClick(index ?? undefined, headId);
+ }}
+ onPageChange={setPageNation}
+ >
+
+
+
+ {
+ setIsChHead(!isChHead);
+ }}
+ bodyClass={""}
+ body={
+ ({
+ ...item,
+ visible: item.visible ?? false,
+ }))}
+ />
+ }
+ />
+ {
+ setDetailModal({ ...detailModal, isOpen: !detailModal.isOpen });
+ }}
+ bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"}
+ body={}
+ />
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx
new file mode 100644
index 000000000..7a7a125d2
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx
@@ -0,0 +1,223 @@
+"use client";
+import { useWrStore } from "@/app/store";
+import { btnClass } from "@/app/store/common/code";
+import {
+ ContentsDiv,
+ SearchBaseForm,
+ SearchInput,
+ SelectBox,
+ Title,
+ UiModal,
+ UiTable,
+ type ReturnType,
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button, Label } from "@common/components/ui";
+import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
+import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
+import { excelDownload, yearOptions } from "@/components/lib/func/commom";
+import SearchInputText from "@/components/ui/searchInput/searchInput";
+import type { WaterReuseFacility } from "@/app/store/ruseFcltMng/fcltSttn/pbnstSttn/type";
+import { PbnstSttnModal } from "@/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal";
+
+export default function PbnstSttn() {
+ const {
+ code,
+ pbnstSttn,
+ pbnstSttnSearch,
+ pbnSttnInit,
+ getPbnStnDetail,
+ pbnNmSearch,
+ } = useWrStore((state) => state);
+
+ const ref = useRef({} as ReturnType);
+ const [searchYear, setSearchYear] = useState(
+ String(new Date().getFullYear())
+ );
+ const [isChHead, setIsChHead] = useState(false);
+ const [bdstTable, setBdstTable] = useState();
+ const [pbnDetaileData, setPbnDetaileData] = useState<{
+ isModal: boolean;
+ data: customPbnst;
+ }>({ isModal: false, data: {} as customPbnst });
+
+ const [pbnRuseNm, setPbnRuseNm] = useState("");
+
+ const excelClick = useCallback(() => {
+ pbnstSttnSearch("1", "10000", ref.current, "", searchYear);
+ }, [pbnstSttnSearch, searchYear, ref.current]);
+
+ const cellCLick = useCallback(
+ (index: number | undefined) => {
+ if (
+ index !== undefined &&
+ pbnstSttn.pbnstSttnRes &&
+ pbnstSttn.pbnstSttnRes[index]
+ ) {
+ const pbnstRuseFcltPk = pbnstSttn.pbnstSttnRes[index].pbnstRuseFcltPk;
+ getPbnStnDetail(pbnstRuseFcltPk);
+ }
+ },
+ [getPbnStnDetail, pbnstSttn.pbnstSttnRes]
+ );
+
+ useEffect(() => {
+ if (pbnstSttn.excelList.length >= 0) {
+ excelDownload(
+ pbnstSttn.excelList,
+ "하수재이용시설 현황",
+ "sample_pbnstSttn.xlsx",
+ "A1:U2"
+ );
+ }
+ }, [pbnstSttn.excelList]);
+ useEffect(() => {
+ if (!pbnstSttn.isInit) {
+ pbnSttnInit("1", "13", ref.current, searchYear);
+ }
+ }, [pbnstSttn.isInit, pbnSttnInit, ref.current]);
+ useEffect(() => {
+ setBdstTable(pbnstSttn.pbnstSttnRes);
+ }, [pbnstSttn.pbnstSttnRes]);
+
+ // useEffect(() => {
+ // pbnstSttnSearch("1", "20", ref.current, pbnRuseNm, searchYear);
+ // }, [pageNation, ref.current, pbnRuseNm, searchYear, pbnstSttnSearch]);
+
+ // useEffect(() => {
+ // if (pbnRuseNm.length > 1)
+ // pbnNmSearch(String(pageNation), "23", ref.current, pbnRuseNm, searchYear);
+ // }, [pbnRuseNm,pageNation]);
+
+ useEffect(() => {
+ if (pbnstSttn.pbnstDetail.pbnstRuseFcltPk)
+ setPbnDetaileData({
+ isModal: true,
+ data: pbnstSttn.pbnstDetail,
+ });
+ }, [pbnstSttn.pbnstDetail]);
+
+ useEffect(() => {
+ console.log("pbnDetaileData.isModal ", pbnDetaileData.isModal);
+ }, [pbnDetaileData.isModal]);
+ return (
+ <>
+
+
+
+
+
{
+ setIsChHead(true);
+ }}
+ >
+ 조회항목설정
+
+ }
+ leftChildren={
+
+
+ setSearchYear(String(val))
+ }
+ />
+
+ {
+ setPbnRuseNm(e || "");
+ }}
+ />
+
+ }
+ queryClick={function (returnType: ReturnType): void {
+ pbnstSttnSearch("1", "20", returnType, pbnRuseNm, searchYear);
+ }}
+ excelClick={excelClick}
+ initClick={function (): void {}}
+ btnClass={btnClass}
+ ref={ref}
+ isAdmin={false}
+ />
+
+
+
+
+
+
+ }
+ headlist={pbnstSttn.pbnstSttHeadList}
+ pageSize={20}
+ total={100000}
+ cellClick={(index: number | undefined, headId: string) => {
+ cellCLick(index);
+ }}
+ onPageChange={(page: number) => {
+ pbnstSttnSearch(
+ String(page),
+ String(13),
+ ref.current,
+ pbnRuseNm,
+ searchYear
+ );
+ }}
+ >
+
+
+
+ {
+ setIsChHead(!isChHead);
+ }}
+ bodyClass={""}
+ body={
+ ({
+ ...item,
+ visible: item.visible ?? false,
+ }))}
+ />
+ }
+ />
+
+ }
+ bodyClass="w-[68vw] max-w-none h-[90vh]"
+ open={pbnDetaileData.isModal}
+ onOpenChange={(open) => {
+ setPbnDetaileData({ data: {} as customPbnst, isModal: false });
+ }}
+ />
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx
new file mode 100644
index 000000000..631e24350
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx
@@ -0,0 +1,216 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+"use client";
+import { useWrStore } from "@/app/store";
+import { btnClass } from "@/app/store/common/code";
+import {
+ excelDownload,
+ getCityOrSgg,
+ tableData,
+} from "@/components/lib/func/commom";
+import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal";
+import {
+ ContentsDiv,
+ SearchBaseForm,
+ Title,
+ UiModal,
+ UiTable,
+ type ReturnType,
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button } from "@common/components/ui";
+import { useCallback, useEffect, useRef, useState } from "react";
+import type {
+ chgBuilding,
+ customRainBdst,
+} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
+import SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal";
+import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
+
+export default function RainSttn() {
+ const { code, rainSttn, rainSttnSearch, rainSttnInit } = useWrStore(
+ (state) => state
+ );
+ const { rainSttnRes } = rainSttn;
+ const ref = useRef({} as ReturnType);
+
+ const [pageNation, setPageNation] = useState(1);
+ const [isChHead, setIsChHead] = useState(false);
+ const [bdstTable, setBdstTable] = useState();
+ const [detailModal, setDetailModal] = useState<{
+ isOpen: boolean;
+ data: customRainBdst | undefined;
+ }>({ data: undefined, isOpen: false });
+ const [bdstChgProps, setBdstChgProps] = useState<{
+ isOpen: boolean;
+ chBuilding: chgBuilding[];
+ }>({ isOpen: false, chBuilding: [] });
+
+ const codeData = getCityOrSgg(ref);
+
+ const cellClick = (index: number | undefined, headId: string) => {
+ if (
+ headId !== "chBuildingYn" &&
+ index !== undefined &&
+ bdstTable !== undefined
+ ) {
+ setDetailModal({ isOpen: true, data: bdstTable[index] });
+ } else if (
+ headId === "chBuildingYn" &&
+ index !== undefined &&
+ bdstTable !== undefined
+ ) {
+ if (
+ bdstTable[index] &&
+ bdstTable[index]?.chgBuilding[0]?.bdstChgNm !== null
+ ) {
+ setBdstChgProps({
+ isOpen: true,
+ chBuilding: bdstTable[index].chgBuilding,
+ });
+ }
+ }
+ };
+
+ useEffect(() => {
+ if (!rainSttn.isInit) {
+ rainSttnInit(codeData ?? "0");
+ }
+ }, [rainSttn.isInit, rainSttnInit]);
+
+ useEffect(() => {
+ if (rainSttnRes.length > 0 && code.cityCd.length > 0) {
+ const data = tableData(rainSttnRes, { code });
+ const chData = data
+ .map((item: any) => ({
+ ...item,
+ ...item.reuseBuilding[0],
+ ...item.reuseBuilding[0].rainyObj,
+ chBuildingYn: item.chgBuilding[0]?.bdstChgNm !== null ? "Y" : "N",
+ }))
+ .filter((item: any) => item.rainyObj !== undefined);
+
+ setBdstTable(chData);
+ }
+ }, [code, rainSttnRes, rainSttn.rainSttHeadList]);
+
+ useEffect(() => {
+ if (codeData != null) rainSttnSearch(pageNation, "20", codeData, code.cityCd, code.sggCd);
+ }, [pageNation]);
+
+ useEffect(() => {
+ if (rainSttn.excelList.length > 0) {
+ if (rainSttn.excelList.length === 0) return;
+ excelDownload(
+ rainSttn.excelList,
+ "빗물재이용시설 현황",
+ "sample_rainSttn.xlsx",
+ "A1:W3"
+ );
+ }
+ }, [rainSttn.excelList]);
+
+ const excelClick = useCallback(() => {
+ if (codeData) rainSttnSearch(1, "10000", codeData, code.cityCd, code.sggCd);
+ }, [rainSttnSearch, codeData, code.cityCd, code.sggCd]);
+
+ return (
+ <>
+
+
+
+
+ {
+ setIsChHead(true);
+ }}
+ >
+ 조회항목설정
+
+ }
+ leftChildren={undefined}
+ queryClick={function (returnType: ReturnType): void {
+ // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}'
+ let con;
+ if (returnType.sigunValue != "0") {
+ con = returnType.sigunValue;
+ } else {
+ con = returnType.sidoValue;
+ }
+ rainSttnSearch(1, "20", con, code.cityCd, code.sggCd);
+ }}
+ excelClick={excelClick}
+ initClick={function (): void { }}
+ btnClass={btnClass}
+ ref={ref}
+ isAdmin={false}
+ />
+
+
+
+
+
+
+ }
+ headlist={rainSttn.rainSttHeadList}
+ pageSize={20}
+ total={100000}
+ cellClick={(index: number | undefined, headId: string) => {
+ cellClick(index ?? undefined, headId);
+ }}
+ onPageChange={setPageNation}
+ >
+
+
+
+ {
+ setIsChHead(!isChHead);
+ }}
+ bodyClass={""}
+ body={
+ ({
+ ...item,
+ visible: item.visible ?? false,
+ }))}
+ />
+ }
+ />
+ {
+ setDetailModal({ ...detailModal, isOpen: !detailModal.isOpen });
+ }}
+ bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"}
+ body={}
+ />
+
+ }
+ onOpenChange={(open) => {
+ setBdstChgProps({ ...bdstChgProps, isOpen: open });
+ }}
+ />
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rswtSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rswtSttn/page.tsx
new file mode 100644
index 000000000..7a3444a9b
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/fcltSttn/rswtSttn/page.tsx
@@ -0,0 +1,199 @@
+"use client";
+import { useWrStore } from "@/app/store";
+import { btnClass } from "@/app/store/common/code";
+import type { chgBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
+import {
+ excelDownload,
+ getCityOrSgg,
+ tableData,
+} from "@/components/lib/func/commom";
+import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
+import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal";
+import SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal";
+import {
+ ContentsDiv,
+ SearchBaseForm,
+ Title,
+ UiModal,
+ UiTable,
+ type ReturnType,
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
+import { Button } from "@common/components/ui";
+import { useCallback, useEffect, useRef, useState } from "react";
+
+export default function RswtSttn() {
+ const { code, rswtSttn, rswtSttnSearch, rswtSttnInit } = useWrStore(
+ (state) => state
+ );
+ const [pageNation, setPageNation] = useState(1);
+
+ const { rswtSttnRes } = rswtSttn;
+ const [isChHead, setIsChHead] = useState(false);
+ const ref = useRef({} as ReturnType);
+ const [bdstTable, setBdstTable] = useState();
+ const [detailModal, setDetailModal] = useState<{ isOpen: boolean, data: customRswtBdst | undefined }>({ data: undefined, isOpen: false })
+ const [bdstChgProps, setBdstChgProps] = useState<{
+ isOpen: boolean;
+ chBuilding: chgBuilding[];
+ }>({ isOpen: false, chBuilding: [] });
+
+ const codeCityOrSgg = getCityOrSgg(ref);
+
+ const cellClick = (index: number | undefined, headId: string) => {
+
+ if (headId !== 'chBuildingYn' && index !== undefined && bdstTable !== undefined) {
+ setDetailModal({ isOpen: true, data: bdstTable[index] })
+ } else if (headId === 'chBuildingYn' && index !== undefined && bdstTable !== undefined) {
+ if (
+ bdstTable[index] &&
+ bdstTable[index]?.chBuildingYn === 'Y'
+
+ ) {
+
+ setBdstChgProps({ isOpen: true, chBuilding: bdstTable[index].chgBuilding });
+ }
+ }
+ }
+
+ useEffect(() => {
+ if (!rswtSttn.isInit) {
+ rswtSttnInit("0");
+ }
+ }, [rswtSttn.isInit, rswtSttnInit]);
+
+ useEffect(() => {
+ if (rswtSttnRes.length > 0 && code.cityCd.length > 0) {
+ const data = tableData(rswtSttnRes, { code });
+ const chData = data
+ .map((item: customRswtBdst) => ({
+ ...item,
+ ...item.reuseBuilding[0],
+ ...item.reuseBuilding[0]?.rswtrObj,
+ chBuildingYn: item?.chgBuilding[0]?.bdstChgNm !== null && item?.chgBuilding.length > 0 ? 'Y' : 'N'
+ }))
+ .filter(
+ (item: customRswtBdst) =>
+ item.reuseBuilding[0]?.rswtrObj !== undefined
+ );
+
+ setBdstTable(chData);
+ }
+ }, [code, rswtSttnRes]);
+
+ useEffect(() => {
+ if (rswtSttn.excelList.length > 0) {
+ if (rswtSttn.excelList.length === 0) return;
+ excelDownload(
+ rswtSttn.excelList,
+ "중수도시설 현황",
+ "sample_rswtSttn.xlsx",
+ "A1:W3",
+ );
+ }
+ }, [rswtSttn.excelList]);
+
+ const excelClick = useCallback(
+ (returnType: ReturnType) => {
+ if (codeCityOrSgg)
+ rswtSttnSearch(1, "10000", codeCityOrSgg, code.cityCd, code.sggCd);
+ },
+ [rswtSttnSearch, code.cityCd, code.sggCd, codeCityOrSgg]
+ );
+
+ useEffect(() => {
+ if (codeCityOrSgg != null) rswtSttnSearch(pageNation, "20", codeCityOrSgg, code.cityCd, code.sggCd);
+ }, [pageNation]);
+
+ return (
+ <>
+
+
+
+
+ {
+ setIsChHead(true);
+ } }
+ >
+ 조회항목설정
+ }
+ leftChildren={undefined}
+ queryClick={function (returnType: ReturnType): void {
+ // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}'
+ if (codeCityOrSgg)
+ rswtSttnSearch(1, "20", codeCityOrSgg, code.cityCd, code.sggCd);
+ } }
+ excelClick={excelClick}
+ initClick={function (): void { } }
+ btnClass={btnClass}
+ ref={ref} isAdmin={false} />
+
+
+
+
+
+
+ }
+ headlist={rswtSttn.rswtSttHeadList}
+ pageSize={20}
+ total={10000}
+ cellClick={(index: number | undefined, headId: string) => { cellClick(index ?? undefined, headId) }}
+ onPageChange={setPageNation}
+ >
+
+
+
+ {
+ setIsChHead(!isChHead);
+ }}
+ bodyClass={""}
+ body={
+ ({
+ ...item,
+ visible: item.visible ?? false,
+ }))}
+ type={"RST"}
+ />
+ }
+ />
+ {
+ setDetailModal({ ...detailModal, isOpen: !detailModal.isOpen });
+ }}
+ bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"}
+ body={}
+ />
+
+
+ }
+ onOpenChange={(open) => {
+ setBdstChgProps({ ...bdstChgProps, isOpen: open });
+ }}
+ />
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx
new file mode 100644
index 000000000..10a0bf85f
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx
@@ -0,0 +1,54 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
+import { TableHead, TableRow } from "@common/components/ui";
+
+export const headMakeprfmnc = (
+ upHeadList: TableUpperProps[],
+ makeHeadNm: chHeadType[]
+ ) => {
+ return (
+ <>
+
+ {upHeadList
+ .filter((data) => data.visible != false)
+ .map((head: TableUpperProps) =>
+ !head.upSequnce ? (
+
+ {head.title}
+
+ ) : head.upSequnce === 1 ? (
+ ch.headNm === head.upName)?.length
+ }
+ >
+ {makeHeadNm.find((ch) => ch.headNm === head.upName)?.text}
+
+ ) : null
+ )}
+
+
+
+ {upHeadList
+ .filter((data) => data.visible != false)
+ .map((head: TableUpperProps) =>
+ makeHeadNm.find((ch) => ch.headNm === head.upName) ? (
+
+ {head.title}
+
+ ) : null
+ )}
+
+ >
+ );
+ };
\ No newline at end of file
diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx
new file mode 100644
index 000000000..18dbc7943
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx
@@ -0,0 +1,283 @@
+"use client";
+
+import { useWrStore } from "@/app/store";
+import { type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
+import type {
+ rswtChkZodType,
+ rswtrChkDetailsZodType,
+} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
+import {
+ excelArrayDownload,
+ excelDownload,
+ yearOptions,
+} from "@/components/lib/func/commom";
+import ChkgdExcel from "@/components/ui/modal/chkgd/chkgdExcel/chkgdExcel";
+import ChkgdModal from "@/components/ui/modal/chkgd/chkgdModal/chkgdModal";
+import RainChkgdTable from "@/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable";
+import RswtChkgdTable from "@/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable";
+import {
+ ContentsDiv,
+ SearchDiv,
+ SearchFormLeft,
+ SearchFormRight,
+ SearchInput,
+ SelectBox,
+ Title,
+ UiModal,
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button, Label } from "@common/components/ui";
+import { useCallback, useEffect, useState } from "react";
+import { Toaster } from "react-hot-toast";
+import { shallow } from "zustand/shallow";
+
+//-----------------------
+export default function Page() {
+ const {
+ code,
+ rainChkgdn,
+ rswtChkgdn,
+ rainChkInit,
+ rainChkDetilUpdate,
+ rainChkDelete,
+ rainChkExcelDownload,
+ rainChkHeadChange,
+ isRainSttn,
+
+ rswtChkgdnInit,
+ rswtChkPolInit,
+ rswtChkDetilsUpdate,
+ rswtChkDelete,
+ rswtrChkExcelDownload,
+ rswtChkHeadChange,
+ } = useWrStore((state) => {
+ return state;
+ });
+ const [isRegExcel, setIsRegExcel] = useState(false);
+ const [updateRainDetail, setUpdateRainDetail] = useState(
+ []
+ );
+ const [updateRswtDetail, setUpdateRSwtDetail] = useState<
+ rswtrChkDetailsZodType[]
+ >([]);
+ const [deleteIdx, setDeleteIdx] = useState([]);
+
+ const [selFcltDiv, setSelFcltDiv] = useState("RNB");
+ const [isModal, setIsModal] = useState({
+ open: false,
+ data: {},
+ });
+ const cellClick = () => {
+ if (searchYear) rainChkInit(searchYear, "0");
+ };
+
+ const [searchYear, setSearchYear] = useState(
+ String(new Date().getFullYear())
+ );
+
+ useEffect(() => {
+ if (!rainChkgdn.isInit) {
+ rainChkInit(new Date().getFullYear().toString(), "0");
+ isRainSttn(false);
+ setIsModal({ data: {}, open: false });
+ setIsRegExcel(false);
+ }
+
+ if (!rswtChkgdn.isInit) {
+ rswtChkgdnInit(new Date().getFullYear().toString(), "0");
+ setIsModal({ data: {}, open: false });
+ setIsRegExcel(false);
+ }
+ }, [rainChkgdn.isInit, rainChkInit]);
+
+ useEffect(() => {
+ if (rswtChkgdn.excelList[0]&&rswtChkgdn.excelList[0]?.data.length > 1) {
+
+ excelArrayDownload(
+ "중수도시설 지도점검",
+ "sample_rs_chk.xlsx",
+ rswtChkgdn.excelList
+ );
+ }
+ }, [rswtChkgdn.excelList]);
+
+ useEffect(() => {
+ excelDownload(
+ rainChkgdn.excelList,
+ "빗물이용시설 지도점검",
+ "sample_rainy.xlsx",
+ "A1:AN1",
+ 2
+ );
+ }, [rainChkgdn.excelList]);
+
+ const excelClick = useCallback(() => {
+ if (selFcltDiv === "RNB") {
+ rainChkExcelDownload(code.cityCd, code.sggCd);
+ } else {
+ rswtrChkExcelDownload(code.cityCd, code.sggCd);
+ }
+ }, [
+ rainChkExcelDownload,
+ rswtrChkExcelDownload,
+ code.cityCd,
+ code.sggCd,
+ selFcltDiv,
+ ]);
+
+ const handleClick = useCallback(
+ (data: any) => {
+ if (data) setIsModal({ open: !isModal.open, data: data });
+ },
+ [isModal]
+ );
+
+ useEffect(() => {
+ rainChkgdn.isSttn = false;
+ rswtChkgdn.isSttn = false;
+ if (!rainChkgdn.isSttn && !rswtChkgdn.isSttn) {
+ rainChkHeadChange({ rainChkgdn }, true);
+ rswtChkHeadChange({ rswtChkgdn }, true);
+ }
+ }, [rainChkgdn.isSttn, rswtChkgdn.isSttn]);
+
+ const clickDelete = (data: number[], selFcltDiv: string) => {
+ if (data.length > 0) {
+ if (selFcltDiv === "RNB") {
+ rainChkDelete(data);
+ } else {
+ rswtChkDelete(data);
+ }
+ }
+ };
+ const chkUpdateTable = (selFcltDiv: string) => {
+ if (selFcltDiv === "RNB") {
+ rainChkDetilUpdate(updateRainDetail);
+ } else {
+ rswtChkDetilsUpdate(updateRswtDetail);
+ }
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+ setSearchYear(String(val))
+ }
+ />
+
+
+
+ {
+ if(val === "RST") rswtChkPolInit();
+ setSelFcltDiv(String(val))
+ }
+ }
+ value={selFcltDiv ?? rainChkgdn.fcltDiv[0]?.val}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {selFcltDiv === "RNB" ? (
+
+ ) : (
+
+ )}
+
+
+
+ {
+ setIsModal({ open: !open, data: {} });
+ }}
+ bodyClass={"w-[80vw] max-w-none"}
+ body={}
+ >
+ }
+ />
+
+
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx
new file mode 100644
index 000000000..6be50a8c5
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx
@@ -0,0 +1,279 @@
+"use client";
+import { useWrStore } from "@/app/store";
+import type { pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
+import { excelDownload, yearOptions } from "@/components/lib/func/commom";
+import PbnPrfExcelModal from "@/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal";
+import {
+ ContentsDiv,
+ Title,
+ SearchDiv,
+ SearchFormLeft,
+ SelectBox,
+ SearchInput,
+ SearchFormRight,
+ ScrollArea,
+ UiTable,
+ UiModal,
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import {
+ Button,
+ Label,
+ Table,
+ TableBody,
+ TableHeader,
+} from "@common/components/ui";
+import { useState, useEffect, useCallback } from "react";
+import { set } from "react-hook-form";
+import { Toaster } from "react-hot-toast";
+import { headMakeprfmnc } from "../chkgdnReg/TableHead";
+import { InputTableBody } from "@/components/lib/func/TableData";
+import {
+ initValInUsage,
+ initValOutUsage,
+ subTotalObj,
+ totalObj,
+ type FcPrfType,
+ type PrfType,
+} from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
+import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel";
+
+export default function prfmncPrfmncReg() {
+ const { code, prfmnc, prfmncHasuInit, prfmnRegData } = useWrStore(
+ (state) => state
+ );
+ const { pbnstPrfmncHeadList, monthHeadList, prfmncRes } = prfmnc;
+ const [bdstTable, setbdstTable] = useState();
+ const [searchTxt, setSearchTxt] = useState();
+ const [isExcelOpen, setIsExcelOPen] = useState<{
+ isModal: boolean;
+ data: FcPrfType;
+ }>({ isModal: false, data: {} as FcPrfType });
+ const [inputData, setInputData] = useState();
+ const [pbnstRuseFcltPk, setPbnstRuseFcltPk] = useState();
+ const [pageNation , setPageNation] = useState(1);
+
+ const [searchYear, setSearchYear] = useState(
+ String(new Date().getFullYear())
+ );
+ const excelClick = useCallback(() => {
+ excelDownload(
+ [[]],
+ "하수재이용실적",
+ "sample_pbnstPrfmncReg.xlsx",
+ "A1:O1"
+ );
+ }, [prfmnc.excelList]);
+
+ const onSave = useCallback(() => {
+ if (pbnstRuseFcltPk) {
+ prfmnRegData(
+ excelToPbnPrfData(
+ inputData as unknown as JSON[],
+ searchYear,
+ pbnstRuseFcltPk
+ ) as unknown as PrfType
+ );
+ prfmncHasuInit(String(pageNation), "41");
+ }
+ }, [inputData, searchYear, pbnstRuseFcltPk,prfmncHasuInit,pageNation]);
+
+
+
+
+ const cellClick = useCallback(
+ (index: number | undefined, headId: string) => {
+ if (index !== undefined) {
+ setIsExcelOPen({
+ isModal: false,
+ data: prfmncRes[index] || ({} as FcPrfType),
+ });
+ const inUsageData = structuredClone(initValInUsage);
+ const outUsageData = structuredClone(initValOutUsage);
+ const inSubtotal = structuredClone(subTotalObj);
+ const outSubtotal = structuredClone(subTotalObj);
+ if (prfmncRes[index]?.prfList) {
+ prfmncRes[index].prfList?.forEach((prfItem) => {
+ const month = Number(prfItem?.ym?.slice(4)); // "MM"
+ const monthKey = `${month}월`;
+
+ inUsageData.forEach((inData: any) => {
+ const usageKey = inData.usage;
+ const value = (prfItem as any)[usageKey] ?? 0;
+
+ inData[monthKey] = value;
+ inData.total += value;
+
+ if (inSubtotal && usageKey !== "subtotal") {
+ (inSubtotal as any)[monthKey] =
+ ((inSubtotal as any)[monthKey] ?? 0) + value;
+ inSubtotal.total += value;
+ }
+ });
+
+ outUsageData.forEach((outData: any) => {
+ const usageKey = outData.usage;
+ const value = (prfItem as any)[usageKey] ?? 0;
+
+ outData[monthKey] = value;
+ outData.total += value;
+
+ if (usageKey !== "subtotal") {
+ (outSubtotal as any)[monthKey] =
+ ((outSubtotal as any)[monthKey] ?? 0) + value;
+ outSubtotal.total += value;
+ }
+ });
+ });
+ inUsageData.push(inSubtotal);
+ outUsageData.push(outSubtotal);
+ const usageTotalObj: { [key: string]: any } = structuredClone(totalObj);
+ for (const key in usageTotalObj) {
+ if (["usage", "gubun", "edit"].includes(key)) continue;
+ const val =
+ (Number((inSubtotal as any)[key]) || 0) +
+ (Number((outSubtotal as any)[key]) || 0);
+
+ (usageTotalObj as any)[key] = val;
+ }
+ const tableData = [...inUsageData, ...outUsageData, usageTotalObj];
+ setPbnstRuseFcltPk(prfmncRes[index].pbnstRuseFcltPk);
+
+ setInputData(tableData);
+ } else {
+ setInputData([]);
+ }
+ }
+ },
+ [prfmncRes]
+ );
+
+ useEffect(() => {
+ if (!prfmnc.isInit) {
+ prfmncHasuInit('1', "41");
+ }
+ }, [prfmnc.isInit, prfmncHasuInit]);
+ useEffect(() => {
+ setbdstTable(prfmncRes);
+ }, [prfmncRes]);
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+ setSearchYear(String(val))
+ }
+ />
+
+
+
+ {
+ setSearchTxt(e);
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ cellClick(index, headId);
+ }}
+ onPageChange={setPageNation}
+ children={undefined}
+ />
+
+
+
+
+
+
+
+ {"하수처리수재이용 실적(m3) 등록결과"}
+
+
+
+
+
+ {headMakeprfmnc(monthHeadList, [])}
+
+
+ {InputTableBody(inputData ?? [], monthHeadList, setInputData)}
+
+
+
+
+
+
+ }
+ open={isExcelOpen.isModal}
+ onOpenChange={() => {
+ setIsExcelOPen({ isModal: false, data: {} as FcPrfType });
+ }}
+ >
+
+ >
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx b/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx
new file mode 100644
index 000000000..f9a799c24
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx
@@ -0,0 +1,187 @@
+"use client";
+
+import { useWrStore } from "@/app/store";
+import { type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
+import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
+import {
+ excelArrayDownload,
+ excelDownload,
+ yearOptions,
+} from "@/components/lib/func/commom";
+import ChkgdExcel from "@/components/ui/modal/chkgd/chkgdExcel/chkgdExcel";
+import ChkgdModal from "@/components/ui/modal/chkgd/chkgdModal/chkgdModal";
+import RainChkgdTable from "@/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable";
+import RswtChkgdTable from "@/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable";
+import {
+ ContentsDiv,
+ SearchDiv,
+ SearchFormLeft,
+ SearchFormRight,
+ SearchInput,
+ SelectBox,
+ Title,
+ UiModal,
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button, Label } from "@common/components/ui";
+import { useCallback, useEffect, useState } from "react";
+import { Toaster } from "react-hot-toast";
+
+//-----------------------
+export default function Page() {
+ const {
+ code,
+ rainChkSttn,
+ rswtChkSttn,
+
+
+ rainChkSttnInit,
+ rainChkSttnSearch,
+ rswtChkSttnInit,
+ isRainSttn,
+ isRswtSttn
+ } = useWrStore((state) => {
+ return state;
+ });
+
+ const [selFcltDiv, setSelFcltDiv] = useState("RNB");
+ const [isModal, setIsModal] = useState({
+ open: false,
+ data: {},
+ });
+ const [searchYear, setSearchYear] = useState(String(new Date().getFullYear()));
+ const cellClick = () => {
+ if (searchYear) rainChkSttnSearch(searchYear, "0");
+ };
+
+ useEffect(() => {
+ if (!rainChkSttn.isInit) {
+ isRainSttn(true)
+ rainChkSttnInit( "0");
+ setIsModal({ data: {}, open: false });
+ }
+ }, [rainChkSttn.isInit, rainChkSttnInit]);
+
+ useEffect(() => {
+
+ if (!rswtChkSttn.isInit) {
+ setIsModal({ data: {}, open: false });
+ rswtChkSttnInit( "0");
+ isRswtSttn(true)
+ }
+ },[rswtChkSttn.isInit, rswtChkSttnInit])
+
+
+ const handleClick = useCallback(
+ (data: any) => {
+ if (data) setIsModal({ open: !isModal.open, data: data });
+ },
+ [isModal]
+ );
+const excelDown=() =>{
+ if(rainChkSttn.sttnExcelList && selFcltDiv === "RNB"){
+ excelDownload(
+ rainChkSttn.sttnExcelList,
+ "빗물이용시설 지도점검 현황",
+ "sample_rainChkSttn.xlsx",
+ "A1:Q2",
+ 3
+ );
+ }else if(rswtChkSttn.sttnExcelList && selFcltDiv === "RST"){
+ excelDownload(
+ rswtChkSttn.sttnExcelList,
+ "중수도시설 지도점검 현황",
+ "sample_rswtChkSttn.xlsx",
+ "A1:X2",
+ 3
+ );
+ }
+}
+
+ return (
+
+
+
+
+
+
+
+
+
+ setSearchYear(String(val))
+ }
+ />
+
+
+
+
+ setSelFcltDiv(String(val))
+ }
+ value={selFcltDiv ?? rainChkSttn.fcltDiv[0]?.val}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {selFcltDiv === "RNB" ? (
+ {}}
+ detailUp={() => {}}
+ handleClick={handleClick}
+ rainChkData={rainChkSttn.rainChkRes}
+ />
+ ) : (
+ {}}
+ deleteRswtData={() => {}}
+ handleRswtClick={handleClick}
+ rswtChkData={rswtChkSttn.rswtChkRes}
+ />
+ )}
+
+
+
+ {
+ setIsModal({ open: !open, data: {} });
+ }}
+ bodyClass={"w-[80vw] max-w-none"}
+ body={}
+ >
+
+
+ );
+}
diff --git a/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx b/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx
new file mode 100644
index 000000000..a50c08071
--- /dev/null
+++ b/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx
@@ -0,0 +1,650 @@
+"use client";
+
+import { useWrStore } from "@/app/store";
+import { btnClass } from "@/app/store/common/code";
+import { initValInUsage, initValOutUsage, subTotalObj, totalObj, type FcPrfType, type PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
+import { excelPrfmncSttnParsing } from "@/app/store/prfmncSttn/pbnstPrfmncSttn/excel";
+import { excelDownload, yearOptions } from "@/components/lib/func/commom";
+import SearchInputText from "@/components/ui/searchInput/searchInput";
+import { CHART_FORM, ContentsDiv, MainChart, ScrollArea, SearchBaseForm, SearchInput, SelectBox, Title, UiTable, type ChartConfig, type ReturnType } from "@common/business_components";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button, Label } from "@common/components/ui";
+import { useCallback, useEffect, useRef, useState } from "react";
+import toast, { Toaster } from "react-hot-toast";
+
+export default function PbnstPrfmncSttn() {
+ const {
+ code,
+ tableHeadMaker,
+ pbnstPrfmncSttn,
+ pbnstPrfmncInit,
+ pbnstPrfmncSearch,
+ prfmnc,
+ pbnstSttn,
+ pbnNmSearch
+ } = useWrStore((state) => state);
+ const { monthHeadList } = prfmnc
+ const { pbnstPrfHeadList, prfmncRes, rawData, selectYearList } = pbnstPrfmncSttn;
+ const [isChHead, setIsChHead] = useState(false);
+ const [fromDate, setFromDate] = useState(String(new Date().getFullYear()));
+ const [toDate, setToDate] = useState(String(new Date().getFullYear()));
+ const [year, setYear] = useState(String(new Date().getFullYear()));
+ const [bdstTable, setbdstTable] = useState();
+ const ref = useRef({} as ReturnType);
+ const [swtrmtFcltNm, setSwtrmtFcltNm] = useState();
+ const [pbnRuseNm, setPbnRuseNm] = useState("");
+
+ const [searchYear, setSearchYear] = useState(
+ String(new Date().getFullYear())
+ );
+ const [excelData, setExcelData] = useState([]);
+ const excelClick = useCallback(() => {
+ excelDownload(
+ excelData,
+ "하수재이용실적 현황",
+ "sample_pbnstPrfmncSttn.xlsx",
+ "A1:N1",
+ 2
+ );
+ }, [excelData]);
+ const [chartConfig, setChartConfig] = useState({});
+ const [chartData, setChartData] = useState([]);
+ const [dnInUsage, setDnInUsage] = useState([]);
+ const [dnInChartConfig, setDnInChartConfig] = useState({});
+ const [dnOutUsage, setDnOutUsage] = useState([]);
+ const [dnOutChartConfig, setDnOutChartConfig] = useState({});
+ const [barData, setBarData] = useState([]);
+ const [barChartConfig, setBarChartConfig] = useState({});
+ const [prfData, setPrfData] = useState();
+ const [lnInChartConfig, setLnInChartConfig] = useState({});
+ const [lnOutChartConfig, setLnOutChartConfig] = useState({});
+ const [inLineData, setInLineData] = useState<{
+ chartData1: lineChartDataProps[];
+ chartData2: lineChartDataProps[];
+ chartData3: lineChartDataProps[];
+ chartData4: lineChartDataProps[];
+ chartData5: lineChartDataProps[];
+ chartData6: lineChartDataProps[];
+ chartData7: lineChartDataProps[];
+ chartData8: lineChartDataProps[];
+ chartData9: lineChartDataProps[];
+ }>();
+ const [outLineData, setOutLineData] = useState<{
+ chartData1: lineChartDataProps[];
+ chartData2: lineChartDataProps[];
+ chartData3: lineChartDataProps[];
+ chartData4: lineChartDataProps[];
+ chartData5: lineChartDataProps[];
+ chartData6: lineChartDataProps[];
+ }>();
+
+ type dnChartForm = { label: string, val: number, fill?: string };
+ type barChartForm = { label: string, "장내용수": number, "장외용수": number };
+ type lineChartDataProps = { label: string, val: number, color: string };
+
+ const prfTableData = (prfList: PrfType[], year: string) => {
+ const inUsageData = structuredClone(initValInUsage);
+ const outUsageData = structuredClone(initValOutUsage);
+
+ const inSubtotal = structuredClone(subTotalObj);
+ const outSubtotal = structuredClone(subTotalObj);
+
+ const prfFilter = prfList?.filter((e) => e.ym.slice(0, 4) === year)
+ if (prfList && prfFilter.length > 0) {
+
+ prfList?.forEach((prfItem) => {
+ const month = Number(prfItem?.ym?.slice(4)); // "MM"
+ const monthKey = `${month}월`;
+
+ inUsageData.forEach((inData: any) => {
+ const usageKey = inData.usage;
+ const value = (prfItem as any)[usageKey] ?? 0;
+
+ inData[monthKey] = value;
+ inData.total += value;
+
+ if (inSubtotal && usageKey !== "subtotal") {
+ (inSubtotal as any)[monthKey] =
+ ((inSubtotal as any)[monthKey] ?? 0) + value;
+ inSubtotal.total += value;
+ }
+ });
+
+ outUsageData.forEach((outData: any) => {
+ const usageKey = outData.usage;
+ const value = (prfItem as any)[usageKey] ?? 0;
+
+ outData[monthKey] = value;
+ outData.total += value;
+
+ if (usageKey !== "subtotal") {
+ (outSubtotal as any)[monthKey] =
+ ((outSubtotal as any)[monthKey] ?? 0) + value;
+ outSubtotal.total += value;
+ }
+ });
+ });
+ inUsageData.push(inSubtotal);
+ outUsageData.push(outSubtotal);
+ const usageTotalObj: { [key: string]: any } = structuredClone(totalObj);
+ for (const key in usageTotalObj) {
+ if (["usage", "gubun", "edit"].includes(key)) continue;
+ const val =
+ (Number((inSubtotal as any)[key]) || 0) +
+ (Number((outSubtotal as any)[key]) || 0);
+
+ (usageTotalObj as any)[key] = val;
+ }
+ const tableData = [...inUsageData, ...outUsageData, usageTotalObj];
+ setPrfData(tableData);
+ setExcelData(excelPrfmncSttnParsing(prfData ?? []))
+ } else {
+ setPrfData([]);
+ }
+ }
+
+ const [chartId, setChartId] = useState();
+ useEffect(() => {
+ // 누적 변수 초기화
+ let wshwtr = 0,
+ coolUswtr = 0,
+ cleanUswtr = 0,
+ drwtUswtr = 0,
+ dltnUswtr = 0,
+ ithlRswtr = 0,
+ ithlEtcUswtr = 0,
+ cleanToilUswtr = 0,
+ resn = 0;
+
+ let lndwtr = 0,
+ hydUswtr = 0,
+ ugwtChr = 0,
+ farmUswtr = 0,
+ rvrKeepUswtr = 0,
+ indstUswtr = 0;
+
+ let inUsageSum = 0,
+ outUsageSum = 0;
+
+ let inUsageArr: number[] = [],
+ outUsageArr: number[] = [];
+
+ // 라인차트용 데이터
+ const wshwtrData: lineChartDataProps[] = [],
+ coolUswtrData: lineChartDataProps[] = [],
+ cleanUswtrData: lineChartDataProps[] = [],
+ drwtUswtrData: lineChartDataProps[] = [],
+ dltnUswtrData: lineChartDataProps[] = [],
+ ithlRswtrData: lineChartDataProps[] = [],
+ ithlEtcUswtrData: lineChartDataProps[] = [],
+ cleanToilUswtrData: lineChartDataProps[] = [],
+ resnData: lineChartDataProps[] = [];
+ const lndwtrData: lineChartDataProps[] = [],
+ hydUswtrData: lineChartDataProps[] = [],
+ ugwtChrData: lineChartDataProps[] = [],
+ farmUswtrData: lineChartDataProps[] = [],
+ rvrKeepUswtrData: lineChartDataProps[] = [],
+ indstUswtrData: lineChartDataProps[] = [];
+
+ // 막대차트 데이터
+ const barData: barChartForm[] = [];
+
+ // 도넛차트 데이터
+ const dnData: dnChartForm[] = [];
+ const dnInData: dnChartForm[] = [];
+ const dnOutData: dnChartForm[] = [];
+
+ if (rawData) {
+ prfTableData([], year)
+ rawData.forEach((item) => {
+ // 실적 테이블 데이터
+ if (chartId){
+ if(item.prfList?.[0]?.ym.slice(0, 4) === year && item.prfList?.[0]?.pbnstRuseFcltFk === chartId){
+ prfTableData(item.prfList, year);
+ }
+ item.prfList.filter((e) => e.ym.slice(0, 4) === year && e.pbnstRuseFcltFk === chartId).forEach((element) => {
+ // 누적
+ wshwtr += element.wshwtr;
+ coolUswtr += element.coolUswtr;
+ cleanUswtr += element.cleanUswtr;
+ drwtUswtr += element.drwtUswtr;
+ dltnUswtr += element.dltnUswtr;
+ ithlRswtr += element.ithlRswtr;
+ ithlEtcUswtr += element.ithlEtcUswtr;
+ cleanToilUswtr += element.cleanToilUswtr;
+ resn += element.resn;
+ lndwtr += element.lndwtr;
+ hydUswtr += element.hydUswtr;
+ ugwtChr += element.ugwtChr;
+ farmUswtr += element.farmUswtr;
+ rvrKeepUswtr += element.rvrKeepUswtr;
+ indstUswtr += element.indstUswtr;
+
+ // 월별 합계
+ inUsageSum = element.wshwtr
+ + element.coolUswtr
+ + element.cleanUswtr
+ + element.drwtUswtr
+ + element.dltnUswtr
+ + element.ithlRswtr
+ + element.ithlEtcUswtr
+ + element.cleanToilUswtr
+ + element.resn;
+ outUsageSum = element.lndwtr
+ + element.hydUswtr
+ + element.ugwtChr
+ + element.farmUswtr
+ + element.rvrKeepUswtr
+ + element.indstUswtr;
+ inUsageArr.push(inUsageSum);
+ outUsageArr.push(outUsageSum);
+
+ // 막대차트
+ const month = Number(element.ym.slice(4, 6));
+ barData.push({ label: `${month}월`, "장내용수": inUsageSum, "장외용수": outUsageSum });
+
+ // 라인차트
+ wshwtrData.push({ label: `${month}월`, val: element.wshwtr, color: "red" });
+ coolUswtrData.push({ label: `${month}월`, val: element.coolUswtr, color: "orange" });
+ cleanUswtrData.push({ label: `${month}월`, val: element.cleanUswtr, color: "yellow" });
+ drwtUswtrData.push({ label: `${month}월`, val: element.drwtUswtr, color: "pink" });
+ dltnUswtrData.push({ label: `${month}월`, val: element.dltnUswtr, color: "purple" });
+ ithlRswtrData.push({ label: `${month}월`, val: element.ithlRswtr, color: "green" });
+ ithlEtcUswtrData.push({ label: `${month}월`, val: element.ithlEtcUswtr, color: "blue" });
+ cleanToilUswtrData.push({ label: `${month}월`, val: element.cleanToilUswtr, color: "magenta" });
+ resnData.push({ label: `${month}월`, val: element.resn, color: "skyblue" });
+
+ lndwtrData.push({ label: `${month}월`, val: element.lndwtr, color: "red" });
+ hydUswtrData.push({ label: `${month}월`, val: element.hydUswtr, color: "orange" });
+ ugwtChrData.push({ label: `${month}월`, val: element.ugwtChr, color: "yellow" });
+ farmUswtrData.push({ label: `${month}월`, val: element.farmUswtr, color: "green" });
+ rvrKeepUswtrData.push({ label: `${month}월`, val: element.rvrKeepUswtr, color: "blue" });
+ indstUswtrData.push({ label: `${month}월`, val: element.indstUswtr, color: "purple" });
+ });
+ }
+ });
+
+ // 도넛차트 데이터
+ dnData.push({ label: "세척수", val: wshwtr, fill: "red" });
+ dnData.push({ label: "냉각수", val: coolUswtr, fill: "orange" });
+ dnData.push({ label: "청소수", val: cleanUswtr, fill: "yellow" });
+ dnData.push({ label: "식수대", val: drwtUswtr, fill: "green" });
+ dnData.push({ label: "희석용수", val: dltnUswtr, fill: "skyblue" });
+ dnData.push({ label: "중수도", val: ithlRswtr, fill: "blue" });
+ dnData.push({ label: "기타", val: ithlEtcUswtr, fill: "purple" });
+ dnData.push({ label: "청소화장실용수", val: cleanToilUswtr, fill: "red" });
+ dnData.push({ label: "세척살수용수", val: resn, fill: "orange" });
+ dnData.push({ label: "조경용수", val: lndwtr, fill: "yellow" });
+ dnData.push({ label: "친수용수", val: hydUswtr, fill: "green" });
+ dnData.push({ label: "지하수충전", val: ugwtChr, fill: "skyblue" });
+ dnData.push({ label: "농업용수", val: farmUswtr, fill: "blue" });
+ dnData.push({ label: "하천등유지용수", val: rvrKeepUswtr, fill: "purple" });
+ dnData.push({ label: "공업용수", val: indstUswtr, fill: "black" });
+
+ // 장내용수 도넛
+ dnInData.push({ label: "세척수", val: wshwtr, fill: "yellow" });
+ dnInData.push({ label: "냉각수", val: coolUswtr, fill: "green" });
+ dnInData.push({ label: "청소수", val: cleanUswtr, fill: "yellow" });
+ dnInData.push({ label: "식수대", val: drwtUswtr, fill: "green" });
+ dnInData.push({ label: "희석용수", val: dltnUswtr, fill: "yellow" });
+ dnInData.push({ label: "중수도", val: ithlRswtr, fill: "green" });
+ dnInData.push({ label: "기타", val: ithlEtcUswtr, fill: "yellow" });
+ dnInData.push({ label: "청소화장실용수", val: cleanToilUswtr, fill: "green" });
+ dnInData.push({ label: "세척살수용수", val: resn, fill: "yellow" });
+
+ // 장외용수 도넛
+ dnOutData.push({ label: "조경용수", val: lndwtr, fill: "yellow" });
+ dnOutData.push({ label: "친수용수", val: hydUswtr, fill: "black" });
+ dnOutData.push({ label: "지하수충전", val: ugwtChr, fill: "yellow" });
+ dnOutData.push({ label: "농업용수", val: farmUswtr, fill: "black" });
+ dnOutData.push({ label: "하천등유지용수", val: rvrKeepUswtr, fill: "yellow" });
+ dnOutData.push({ label: "공업용수", val: indstUswtr, fill: "black" });
+
+ // 라인차트 데이터
+ setInLineData({
+ chartData1: wshwtrData,
+ chartData2: coolUswtrData,
+ chartData3: cleanUswtrData,
+ chartData4: drwtUswtrData,
+ chartData5: dltnUswtrData,
+ chartData6: ithlRswtrData,
+ chartData7: ithlEtcUswtrData,
+ chartData8: cleanToilUswtrData,
+ chartData9: resnData
+ });
+ setOutLineData({
+ chartData1: lndwtrData,
+ chartData2: hydUswtrData,
+ chartData3: ugwtChrData,
+ chartData4: farmUswtrData,
+ chartData5: rvrKeepUswtrData,
+ chartData6: indstUswtrData,
+ });
+ setBarData(barData);
+ setChartData(dnData);
+ setDnInUsage(dnInData);
+ setDnOutUsage(dnOutData);
+ }
+ }, [rawData, year, chartId]);
+
+ useEffect(() => {
+ const newChartConfig = chartData.reduce((config, element) => {
+ config[element.label] = {
+ label: element.label,
+ fill: element.fill
+ };
+ return config;
+ }, {} as Record) satisfies ChartConfig;
+ setChartConfig(newChartConfig);
+ }, [chartData]);
+
+ useEffect(() => {
+ const newChartConfig = dnInUsage.reduce((config, element) => {
+ config[element.label] = {
+ label: element.label,
+ fill: element.fill
+ };
+ return config;
+ }, {} as Record) satisfies ChartConfig;
+ setDnInChartConfig(newChartConfig);
+ }, [dnInUsage]);
+
+ useEffect(() => {
+ const newChartConfig = dnOutUsage.reduce((config, element) => {
+ config[element.label] = {
+ label: element.label,
+ fill: element.fill
+ };
+ return config;
+ }, {} as Record) satisfies ChartConfig;
+ setDnOutChartConfig(newChartConfig);
+ }, [dnOutUsage]);
+
+ useEffect(() => {
+ const newChartConfig = barData.reduce((config, element) => {
+ config[element.label] = {
+ label: element.label,
+ };
+ return config;
+
+ }, {} as Record) satisfies ChartConfig;
+ setBarChartConfig(newChartConfig);
+ }, [barData]);
+
+ useEffect(() => {
+ if (inLineData?.chartData1) {
+ const newChartConfig = {
+ chartData1: {
+ label: '세척수',
+ color: "red",
+ },
+ chartData2: {
+ label: '냉각수',
+ color: "orange",
+ },
+ chartData3: {
+ label: '청소수',
+ color: "yellow",
+ },
+ chartData4: {
+ label: '식수대',
+ color: "pink",
+ },
+ chartData5: {
+ label: '희석용수',
+ color: "purple",
+ },
+ chartData6: {
+ label: '중수도',
+ color: "green",
+ },
+ chartData7: {
+ label: '기타',
+ color: "blue",
+ },
+ chartData8: {
+ label: '청소화장실용수',
+ color: "magenta",
+ },
+ chartData9: {
+ label: '세척살수용수',
+ color: "skyblue",
+ },
+ } satisfies ChartConfig;
+ setLnInChartConfig(newChartConfig);
+ }
+ }, [inLineData]);
+
+
+ useEffect(() => {
+ if (outLineData?.chartData1) {
+ const newChartConfig = {
+ chartData1: {
+ label: '조경용수',
+ color: "red",
+ },
+ chartData2: {
+ label: '친수용수',
+ color: "orange",
+ },
+ chartData3: {
+ label: '지하수충전',
+ color: "yellow",
+ },
+ chartData4: {
+ label: '농업용수',
+ color: "green",
+ },
+ chartData5: {
+ label: '하천등유지용수',
+ color: "blue",
+ },
+ chartData6: {
+ label: '공업용수',
+ color: "purple",
+ },
+ } satisfies ChartConfig;
+ setLnOutChartConfig(newChartConfig);
+ }
+ }, [outLineData]);
+
+ useEffect(() => {
+ const returnType: ReturnType = {
+ sidoValue: "0",
+ sigunValue: "0",
+ partValue: "A",
+ regionValue: "0",
+ unitWaterShedValue: "",
+ middleRegionValue: "",
+ envPartValue: "",
+ sidoText: "",
+ sigunText: ""
+ }
+ tableHeadMaker(Number(searchYear), Number(searchYear));
+ pbnstPrfmncSearch(returnType, "", searchYear, searchYear)
+ }, []);
+
+ useEffect(() => {
+ setbdstTable(prfmncRes);
+ if(prfmncRes?.[0]?.pbnstRuseFcltPk) setChartId(prfmncRes[0].pbnstRuseFcltPk)
+ }, [prfmncRes]);
+
+
+
+ useEffect(() => {
+ if (pbnRuseNm.length > 1)
+ pbnNmSearch("1", "23", ref.current, pbnRuseNm, searchYear);
+ }, [pbnRuseNm]);
+
+ const cellClick = (index: number | undefined, headId: string) => {
+ if (index !== undefined && headId !== undefined) {
+ setChartId(prfmncRes[index].pbnstRuseFcltPk)
+ }
+ }
+
+ return (
+ <>
+
+
+
+
+
{
+ setIsChHead(true);
+ }}
+ >
+ 조회항목설정
+ }
+ leftChildren={
+
+
+
+ setFromDate(String(val))} />
+ setToDate(String(val))} />
+
+
{
+ setPbnRuseNm(searchNm || "");
+ }}
+ setRtnData={function (rtnData: any[]): void {
+ // setbdstTable(rtnData);
+ }}
+ searchList={pbnstSttn.pbnstSearchData || []}
+ >
+ {/*
{ }} /> */}
+
+
}
+ queryClick={function (returnType: ReturnType): void {
+ pbnstPrfmncSearch(returnType, pbnRuseNm ?? "", fromDate, toDate);
+ if (fromDate && toDate) {
+ const fromNum = Number(fromDate);
+ const toNum = Number(toDate);
+ if (fromNum > toNum) {
+ toast.error("시작년도가 종료년도 이후로 설정할 수 없습니다.");
+ } else {
+ if (toNum - fromNum > 5) {
+ toast.error("최대 5년까지 선택 가능합니다.");
+ } else {
+ tableHeadMaker(fromNum, toNum);
+
+ }
+ }
+ }
+ }}
+ excelClick={excelClick}
+ initClick={function (): void { }}
+ btnClass={btnClass}
+ ref={ref} isAdmin={false} />
+
+
+
+
+
+ {
+ cellClick(index ?? undefined, headId);
+ }}
+ onPageChange={() => { }
+ }
+ index={0}
+ />
+
+
+ 하수재이용실적 상세현황
+
+ setYear(String(val))} />
+ 장내·외 용도별 하수재이용실적 현황(계)
+
+
+ 장내·외 월별 하수재이용실적 현황
+
+ 하수재이용실적 현황
+
+
+
+
+ {"하수처리수재이용 실적(m3) 등록결과"}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
diff --git a/apps/wr/app/stats/matStat/page.tsx b/apps/wr/app/stats/matStat/page.tsx
new file mode 100644
index 000000000..a147ff597
--- /dev/null
+++ b/apps/wr/app/stats/matStat/page.tsx
@@ -0,0 +1,74 @@
+'use client'
+import { useWrStore } from "@/app/store";
+import { yearOptions } from "@/components/lib/func/commom";
+import { ContentsDiv, Title, SearchDiv, SearchFormLeft, SelectBox, UiTable } from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button } from "@common/components/ui";
+import { useState } from "react";
+
+export default function MatStat(){
+const { code, matStat } = useWrStore((state) => {
+ return state;
+ });
+ const [pageNation, setPageNation] = useState(1);
+ const [searchYear, setSearchYear] = useState(
+ String(new Date().getFullYear())
+ );
+
+ return(
+ <>
+
+
+
+
+
+
+
+ setSearchYear(String(val))
+ }
+ />
+
+
+
+
+
+
+ {/*
+
+ */}
+
+
+
+
+
+
+ {/* */}
+ {}}
+ onPageChange={setPageNation}
+ >
+ {/* */}
+
+
+
+
+ >
+ )
+}
\ No newline at end of file
diff --git a/apps/wr/app/stats/rainStat/page.tsx b/apps/wr/app/stats/rainStat/page.tsx
new file mode 100644
index 000000000..08990028f
--- /dev/null
+++ b/apps/wr/app/stats/rainStat/page.tsx
@@ -0,0 +1,275 @@
+"use client";
+
+import { useWrStore } from "@/app/store";
+import type { RainStatProps } from "@/app/store/stats/rainStat";
+import { excelDownload, tableData, yearOptions } from "@/components/lib/func/commom";
+import { downloadExcel } from "@common/business_components";
+
+import {
+ ContentsDiv,
+ ScrollArea,
+ SearchDiv,
+ SelectBox,
+ Title,
+ UiTable
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button } from "@common/components/ui";
+import { useEffect, useState } from "react";
+
+export default function RainStat() {
+ const { code, rainStat, searchRainStatList } = useWrStore((state) => state);
+ const { rainStatList, excelList, rainDetailList } = rainStat;
+
+ const [searchYear, setSearchYear] = useState(
+ String(new Date().getFullYear())
+ );
+ const [exData, setExData] = useState>>();
+ const [bdstTable, setBdstTable] = useState();
+
+ useEffect(() => {
+ searchRainStatList(searchYear);
+ }, [code.cityCd, code.sggCd, searchRainStatList, searchYear])
+
+ const excelDetailDownLoad=() =>{
+ const sidoList = new Set();
+ const sidoDataMap = new Map(); // 시도별 데이터를 저장할 Map
+ const sidoDetailMap = new Map(); // 시도별 상세 데이터를 저장할 Map
+
+ // 먼저 시도별 상세 데이터를 그룹화
+ rainDetailList.forEach((item: RainStatProps[]) => {
+ const sidoVal = item.at(0)?.toString().trim();
+ const sigunVal = item.at(1)?.toString().trim();
+
+ let sidoText = '';
+ let sigunText = '';
+
+ const sido = code.cityCd.find((city) => city.val === sidoVal);
+ const sigun = code.sggCd.find((sgg) => sgg.val === sigunVal);
+
+ sidoText = sido?.text || '';
+ sigunText = sigun?.text || '';
+
+ // 시도, 시군구 코드를 텍스트로 변환하여 데이터에 할당
+ if (item.length > 0) {
+ item[0] = sidoText as unknown as RainStatProps;
+ }
+ if (item.length > 1) {
+ item[1] = sigunText as unknown as RainStatProps;
+ }
+ if (item.length > 2) {
+ item[2] = sidoText+' '+sigunText as unknown as RainStatProps;
+ }
+
+ // 시도별 상세 데이터 수집
+ if (sidoText) {
+ if (!sidoDetailMap.has(sidoText)) {
+ sidoDetailMap.set(sidoText, []);
+ }
+ sidoDetailMap.get(sidoText)!.push(item as unknown as (string | number)[]);
+ }
+
+ // 시도별 합계 데이터 수집
+ if (sidoText && !sidoList.has(sidoText)) {
+ sidoList.add(sidoText);
+ // 시도별 초기 데이터 구조 생성 (예: [시도명, 0, 0, 0, ...])
+ const initialData: (string | number)[] = [sidoText];
+ // 데이터의 나머지 컬럼들을 0으로 초기화 (실제 컬럼 수에 맞게 조정 필요)
+ for (let i = 1; i < item.length; i++) {
+ initialData.push(0);
+ }
+ sidoDataMap.set(sidoText, initialData);
+ }
+ });
+
+ // 시도별 합계 계산
+ rainDetailList.forEach((item: RainStatProps[]) => {
+ const sidoText = item[0]?.toString();
+ if (sidoText && sidoDataMap.has(sidoText)) {
+ const sidoData = sidoDataMap.get(sidoText)!;
+ // 각 컬럼의 값을 합계에 더하기 (1번 인덱스부터 시작)
+ for (let i = 1; i < item.length && i < sidoData.length; i++) {
+ if(i == 2){
+ sidoData[i] = '합계';
+ } else if(i == 3){
+ // 해당 시도의 데이터 개수를 계산
+ const sidoDataCount = rainDetailList.filter((data: unknown[]) =>
+ Array.isArray(data) && data.length > 0 && String(data[0]) === sidoText
+ ).length;
+ sidoData[i] = sidoDataCount;
+ } else if( i == 4){
+ sidoData[i] = '';
+ } else if(i == 6){
+ // 법정 대상 건축물 개수 (인덱스 6이 'Y'인 경우)
+ const bumCnt = rainDetailList.filter((data: unknown[]) =>
+ Array.isArray(data) && data.length > 6 && String(data[0]) === sidoText
+ ).filter((data: unknown[]) => String(data[6]) === '대상').length;
+ sidoData[i] = bumCnt;
+ } else if(i==8){
+ const value = Number(item[8]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==11){
+ const value = Number(item[11]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==12){
+ const value = Number(item[12]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==14){
+ const value = Number(item[14]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ }
+ else {
+ sidoData[i] = '';
+ }
+ }
+ }
+ });
+
+ // 시도별로 합계와 상세 데이터를 순서대로 배치
+ const summaryExcelData: (string | number)[][] = [];
+
+ // 시도별로 순회하면서 합계와 상세 데이터를 추가
+ Array.from(sidoList).forEach((sidoText) => {
+ const sidoSummary = sidoDataMap.get(sidoText);
+ const sidoDetails = sidoDetailMap.get(sidoText) || [];
+
+ if (sidoSummary) {
+ // 시도 합계 데이터 추가
+ summaryExcelData.push(sidoSummary);
+ // 해당 시도의 상세 데이터들 추가
+ sidoDetails.forEach(detail => {
+ summaryExcelData.push(detail);
+ });
+ }
+ });
+
+ const sidoSummaryList = Array.from(sidoDataMap.values());
+ const sidoTotalSummary = [['전체', '', '합계', 0, '', '', 0, '', '', 0, 0, 0, 0, 0, 0, '', 0]];
+ sidoSummaryList.forEach((item: (string | number)[]) => {
+ item.forEach((value: string | number, index: number) => {
+ if(typeof value === 'number') {
+ if (sidoTotalSummary[0] && index < sidoTotalSummary[0].length) {
+ sidoTotalSummary[0][index] = Number(sidoTotalSummary[0][index]) + Number(value);
+ }
+ }
+ });
+ });
+
+ // sidoSummaryList와 rainDetailList를 합쳐서 엑셀 데이터 생성
+ const excelData = [...sidoTotalSummary, ...sidoSummaryList, ...summaryExcelData];
+
+ excelDownload(
+ excelData as unknown as [][],
+ "빗물이용시설 통계",
+ "sample_rainStats.xlsx",
+ "A1:V3",
+ 4
+ );
+ }
+
+ const excelClick = () => {
+ downloadExcel({
+ data: (exData as unknown as JSON[]) ?? [],
+ fileName: "재이용통계",
+ sheetNameArray: ["Sheet1"],
+ headerRange: "A1:M1"
+ })
+ }
+
+ useEffect(() => {
+ const transExcel = Array.isArray(excelList) ? excelList : [excelList];
+ const excelData = tableData(transExcel, { code });
+ const tbData = Array.isArray(excelData)
+ ? excelData.map((item: RainStatProps) => {
+ return {
+ "시도": item.cityText,
+ "개소": item.tmp,
+ "설치비(백만원)": item.instlCst,
+ "저류조용량(m³/년)": item.dtfcltCpct,
+ "연간사용량(m³/년)": item.wtrUsqty,
+ "조경용수": item.lndwtr,
+ "청소화장실용수": item.cleanToilUswtr,
+ "세척살수용수": item.resn,
+ "농업용수": item.farmUswtr,
+ "공업용수": item.indstUswtr,
+ "친수용수": item.hydUswtr,
+ "기타": item.ithlEtcUswtr,
+ "연간운영비(백만원/년)": item.anlOperCst,
+ };
+ })
+ : [];
+ setExData(tbData);
+ }, [code, excelList])
+
+ useEffect(() => {
+ const transData = Array.isArray(rainStatList) ? rainStatList : [rainStatList];
+ const data = tableData(transData, { code });
+ const tbData = Array.isArray(data)
+ ? data.map((item: RainStatProps) => {
+ return {
+ ...item,
+ ctpvCd: item.cityText
+ };
+ })
+ : [];
+ setBdstTable(tbData);
+ }, [code, rainStatList]);
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+ setSearchYear(String(val))
+ }
+ />
+
+
+
+
+
+
+
+
+ {/*
+ */}
+
+
+
+
+ >
+ );
+}
\ No newline at end of file
diff --git a/apps/wr/app/stats/rswtStat/page.tsx b/apps/wr/app/stats/rswtStat/page.tsx
new file mode 100644
index 000000000..c0741433c
--- /dev/null
+++ b/apps/wr/app/stats/rswtStat/page.tsx
@@ -0,0 +1,289 @@
+"use client";
+import { useWrStore } from "@/app/store";
+import type { RswtStatProps } from "@/app/store/stats/rswtStat";
+import { excelDownload, tableData, yearOptions } from "@/components/lib/func/commom";
+import {
+ ContentsDiv,
+ downloadExcel,
+ ScrollArea,
+ SearchDiv,
+ SelectBox,
+ Title,
+ UiTable
+} from "@common/business_components/ui";
+import ListDiv from "@common/business_components/ui/list_div";
+import { Button } from "@common/components/ui";
+import { useEffect, useState } from "react";
+
+export default function RswtStat() {
+ const { code, rswtStat, searchRswtStatList } = useWrStore((state) => state);
+ const { rswtStatList, excelList, rswtDetailList } = rswtStat;
+ const [rswtTable, setRswtTable] = useState();
+ const [searchYear, setSearchYear] = useState(
+ String(new Date().getFullYear())
+ );
+ const [excelData, setExceData] = useState[]>();
+
+ useEffect(() => {
+ searchRswtStatList(searchYear)
+ }, [searchRswtStatList, searchYear])
+
+ const excelClick = () => {
+ downloadExcel({
+ data: (excelData as unknown as JSON[]) ?? [],
+ fileName: "중수도재이용통계",
+ sheetNameArray: ["Sheet1"],
+ headerRange: "A1:O1"
+ })
+ }
+
+ useEffect(() => {
+ const transData = Array.isArray(rswtStatList) ? rswtStatList : [rswtStatList];
+ const data = tableData(transData, { code });
+ const tbData = Array.isArray(data)
+ ? data.map((item: RswtStatProps) => {
+ return {
+ ...item,
+ ctpvCd: item.cityText
+ };
+ })
+ : [];
+ setRswtTable(tbData);
+ }, [code, rswtStatList])
+
+ useEffect(() => {
+ const transExcel = Array.isArray(excelList) ? excelList : [excelList];
+ const exData = tableData(transExcel, { code });
+ const tbData = Array.isArray(exData) ?
+ exData.map((item: RswtStatProps) => {
+ return {
+ "시도": item.cityText,
+ "개소": item.ctpvCnt,
+ "건축연면적(m³)": item.archArea,
+ "처리용량(m³)": item.filtrTrtmfctCpct,
+ "물사용량(m³/년)": item.wtrUsqty,
+ "중수도+대체수이용량(m³/년)": item.rswtAltSum,
+ "중수도이용량(m³/년)": item.rswtrUsqty,
+ "대체수이용량(m³/년)": item.altUswtrUtztnQnt,
+ "조경용수": item.lndwtr,
+ "청소화장실용수": item.cleanToilUswtr,
+ "농업용수": item.farmUswtr,
+ "공업용수": item.indstUswtr,
+ "친수용수": item.hydUswtr,
+ "기타": item.ithlEtcUswtr,
+ "연간운영비(백만원/년)": item.anlOperCst,
+ };
+ }) : [];
+ setExceData(tbData);
+ }, [code, excelList])
+
+ const excelDetailDownLoad=() =>{
+ const sidoList = new Set();
+ const sidoDataMap = new Map(); // 시도별 데이터를 저장할 Map
+ const sidoDetailMap = new Map(); // 시도별 상세 데이터를 저장할 Map
+
+ // 먼저 시도별 상세 데이터를 그룹화
+ rswtDetailList.forEach((item: RswtStatProps[]) => {
+ const sidoVal = item.at(0)?.toString().trim();
+ const sigunVal = item.at(1)?.toString().trim();
+ let sidoText = '';
+ let sigunText = '';
+
+ const sido = code.cityCd.find((city) => city.val === sidoVal);
+ const sigun = code.sggCd.find((sgg) => sgg.val === sigunVal);
+
+ sidoText = sido?.text || '';
+ sigunText = sigun?.text || '';
+
+ // 시도, 시군구 코드를 텍스트로 변환하여 데이터에 할당
+ if (item.length > 0) {
+ item[0] = sidoText as unknown as RswtStatProps;
+ }
+ if (item.length > 1) {
+ item[1] = sigunText as unknown as RswtStatProps;
+ }
+ if (item.length > 2) {
+ item[2] = sidoText+' '+sigunText as unknown as RswtStatProps;
+ }
+
+ // 시도별 상세 데이터 수집
+ if (sidoText) {
+ if (!sidoDetailMap.has(sidoText)) {
+ sidoDetailMap.set(sidoText, []);
+ }
+ sidoDetailMap.get(sidoText)!.push(item as unknown as (string | number)[]);
+ }
+
+ // 시도별 합계 데이터 수집
+ if (sidoText && !sidoList.has(sidoText)) {
+ sidoList.add(sidoText);
+ // 시도별 초기 데이터 구조 생성 (예: [시도명, 0, 0, 0, ...])
+ const initialData: (string | number)[] = [sidoText];
+ // 데이터의 나머지 컬럼들을 0으로 초기화 (실제 컬럼 수에 맞게 조정 필요)
+ for (let i = 1; i < item.length; i++) {
+ initialData.push(0);
+ }
+ sidoDataMap.set(sidoText, initialData);
+ }
+ });
+
+ // 시도별 합계 계산
+ rswtDetailList.forEach((item: RswtStatProps[]) => {
+ const sidoText = item[0]?.toString();
+ if (sidoText && sidoDataMap.has(sidoText)) {
+ const sidoData = sidoDataMap.get(sidoText)!;
+ // 각 컬럼의 값을 합계에 더하기 (1번 인덱스부터 시작)
+ for (let i = 1; i < item.length && i < sidoData.length; i++) {
+ if(i == 2){
+ sidoData[i] = '합계';
+ } else if(i == 3){
+ // 해당 시도의 데이터 개수를 계산
+ const sidoDataCount = rswtDetailList.filter((data: unknown[]) =>
+ Array.isArray(data) && data.length > 0 && String(data[0]) === sidoText
+ ).length;
+ sidoData[i] = sidoDataCount;
+ } else if( i == 4){
+ sidoData[i] = '';
+ } else if(i == 6){
+ // 법정 대상 건축물 개수 (인덱스 6이 'Y'인 경우)
+ const bumCnt = rswtDetailList.filter((data: unknown[]) =>
+ Array.isArray(data) && data.length > 6 && String(data[0]) === sidoText
+ ).filter((data: unknown[]) => String(data[6]) === '대상').length;
+ sidoData[i] = bumCnt;
+ } else if(i==9){
+ const value = Number(item[9]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==10){
+ const value = Number(item[10]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==11){
+ const value = Number(item[11]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==12){
+ const value = Number(item[12]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ }else if(i==13){
+ const value = Number(item[13]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==14){
+ const value = Number(item[14]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else if(i==16){
+ const value = Number(item[16]) || 0;
+ sidoData[i] = (Number(sidoData[i]) + value) as string | number;
+ } else {
+ sidoData[i] = '';
+ }
+ }
+ }
+ });
+
+ // 시도별로 합계와 상세 데이터를 순서대로 배치
+ const summaryExcelData: (string | number)[][] = [];
+
+ // 시도별로 순회하면서 합계와 상세 데이터를 추가
+ Array.from(sidoList).forEach((sidoText) => {
+ const sidoSummary = sidoDataMap.get(sidoText);
+ const sidoDetails = sidoDetailMap.get(sidoText) || [];
+
+ if (sidoSummary) {
+ // 시도 합계 데이터 추가
+ summaryExcelData.push(sidoSummary);
+ // 해당 시도의 상세 데이터들 추가
+ sidoDetails.forEach(detail => {
+ summaryExcelData.push(detail);
+ });
+ }
+ });
+
+ const sidoSummaryList = Array.from(sidoDataMap.values());
+ const sidoTotalSummary = [['전체', '', '합계', 0, '', '', 0, '', '', 0, 0, 0, 0, 0, 0, '', 0]];
+ sidoSummaryList.forEach((item: (string | number)[]) => {
+ item.forEach((value: string | number, index: number) => {
+ if(typeof value === 'number') {
+ if (sidoTotalSummary[0] && index < sidoTotalSummary[0].length) {
+ sidoTotalSummary[0][index] = Number(sidoTotalSummary[0][index]) + Number(value);
+ }
+ }
+ });
+ });
+
+ // sidoSummaryList와 rainDetailList를 합쳐서 엑셀 데이터 생성
+ const excelData = [...sidoTotalSummary,...sidoSummaryList, ...summaryExcelData];
+
+ excelDownload(
+ excelData as unknown as [][],
+ "중수도시설 통계",
+ "sample_rswtStats.xlsx",
+ "A1:Q3",
+ 4
+ );
+ }
+
+ return (<>
+
+
+
+
+
+
+
+ setSearchYear(String(val))}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { }}
+ />
+
+
+
+
+
+ >
+ );
+}
diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts
new file mode 100644
index 000000000..e7fca8180
--- /dev/null
+++ b/apps/wr/app/store/common/code/index.ts
@@ -0,0 +1,370 @@
+import { getFetch } from "@/components/lib/api";
+import type { EnvPartSelectDataType, SelectDataType } from "@common/business_components/ui";
+
+
+
+export const btnClass = "p-4 m-2 text-white rounded-sm text-lg font-medium "
+
+const yn: SelectDataType[] = [
+ { val: 'Y', text: 'Y' },
+ { val: 'N', text: 'N' },
+]
+
+//공통 건축물 용도
+const bdstUsgCd: SelectDataType[] = [
+ { val: '-1', text: "확인불가" },
+ { val: '1', text: "운동장" },
+ { val: '2', text: "체육관" },
+ { val: '3', text: "공공업무시설" },
+ { val: '4', text: "공공기관의청사" },
+ { val: '5', text: "아파트" },
+ { val: '6', text: "연립주택" },
+ { val: '7', text: "다세대주택" },
+ { val: '8', text: "기숙사" },
+ { val: '9', text: "초등학교" },
+ { val: '10', text: "중학교" },
+ { val: '11', text: "고등학교" },
+ { val: '12', text: "전문대학" },
+ { val: '13', text: "대학및대학교" },
+ { val: '14', text: "골프장" },
+ { val: '15', text: "대규모점포" },
+ { val: '16', text: "기타" },
+];
+//빗물 집수면 종류 용도
+// const rainFcltCd = [
+// { val: "1", text: "지붕" },
+// { val: "2", text: "건물옥상" },
+// { val: "3", text: "골프장 연못" },
+// { val: "4", text: "운동장 바닥" },
+// { val: "5", text: "운동장 지붕" },
+// { val: "6", text: "주차장" },
+// { val: "7", text: "태양광패널" },
+// { val: "8", text: "연못" },
+// { val: "9", text: "기타" },
+// { val: "10", text: "확인불가" },
+// ];
+// 중수도 필수 원수종류
+const rswtBdstType: SelectDataType[] = [
+ { text: "숙박업", val: "17" },
+ { text: "목욕장업", val: "18" },
+ { text: "공장", val: "19" },
+ { text: "발전시설", val: "20" },
+ { text: "관광단지개발사업", val: "21" },
+ { text: "도시개발사업", val: "22" },
+ { text: "산업단지개발사업", val: "23" },
+ { text: "택지개발사업", val: "24" },
+ { text: "대규모점포(대형마트)", val: "25" },
+ { text: "대규모점포(전문점)", val: "26" },
+ { text: "대규모점포(백화점)", val: "27" },
+ { text: "대규모점포(쇼핑센터)", val: "28" },
+ { text: "대규모점포(복합쇼핑몰)", val: "29" },
+ { text: "물류시설", val: "30" },
+ { text: "운수시설(여객자동차터미널)", val: "31" },
+ { text: "운수시설(철도시설)", val: "32" },
+ { text: "운수시설(공항시설)", val: "33" },
+ { text: "운수시설(항만시설)", val: "34" },
+ { text: "업무시설(공공업무시설)", val: "35" },
+ { text: "업무시설(금융업소)", val: "36" },
+ { text: "업무시설(사무소)", val: "37" },
+ { text: "업무시설(결혼상담소 등 소개업소)", val: "38" },
+ { text: "업무시설(출판사)", val: "39" },
+ { text: "업무시설(신문사)", val: "40" },
+ { text: "업무시설(오피스텔)", val: "41" },
+ { text: "교정시설", val: "42" },
+ { text: "방송국", val: "43" },
+ { text: "전신전화국", val: "44" },
+ { text: "기타", val: "45" }
+];
+
+const orgwtKndCd = [
+ { text: "오수(변기 오수 제외)", val: "1" },
+ { text: "오수", val: "2" },
+ { text: "폐수", val: "3" },
+ { text: "오수 및 폐수", val: "4" },
+ { text: "기타", val: "5" },
+];
+
+const chBuCd = [
+ { val: "증축", text: "증축" },
+ { val: "개축", text: "개축" },
+ { val: "재축", text: "재축" },
+]
+
+
+
+const dmdUszCd = [
+ { val: "조경용수", text: "조경용수" },
+ { val: "청소화장실용수", text: "청소화장실용수" },
+ { val: "농업용수", text: "농업용수" },
+ { val: "공업용수", text: "공업용수" },
+ { val: "친수용수", text: "친수용수" },
+ { val: "기타", text: "기타" },
+
+]
+
+const ruseMngMtd = [
+ { val: "자체운영", text: "자체운영" },
+ { val: "공기업", text: "공기업" },
+ { val: "민간(대행)", text: "민간(대행)" },
+]
+
+
+const pplQulity = [
+ { val: "도복장강관", text: "도복장강관" },
+ { val: "PE관", text: "PE관" },
+ { val: "스테인레스관", text: "스테인레스관" },
+ { val: "덕타일주철관", text: "덕타일주철관" },
+ { val: "유리섬유복합관", text: "유리섬유복합관" },
+ { val: "기타", text: "기타" },
+
+]
+const pplLenght = [
+ { val: "D100", text: "D100" },
+ { val: "D200", text: "D200" },
+ { val: "D250", text: "D250" },
+ { val: "D300", text: "D300" },
+ { val: "D350", text: "D350" },
+ { val: "D400", text: "D400" },
+ { val: "D450", text: "D450" },
+ { val: "D500", text: "D500" },
+ { val: "D700", text: "D700" },
+ { val: "D900", text: "D900" },
+ { val: "D1000", text: "D1000" },
+
+]
+export const buildingType = {
+ RST:"RST",
+ RNB:"RNB",
+ HTB:"HTB"
+}
+
+const rainFcltCd = [
+ { val: "지붕", text: "지붕" },
+ { val: "건물옥상", text: "건물옥상" },
+ { val: "골프장 연못", text: "골프장 연못" },
+ { val: "운동장 바닥", text: "운동장 바닥" },
+ { val: "운동장 지붕", text: "운동장 지붕" },
+ { val: "주차장", text: "주차장" },
+ { val: "태양광패널", text: "태양광패널" },
+ { val: "연못", text: "연못" },
+ { val: "기타", text: "기타" },
+ { val: "확인불가", text: "확인불가" },
+];
+
+export type comCodeState = {
+ code: {
+ isInit: boolean;
+ chBuCd: SelectDataType[]
+ rainFcltCd: SelectDataType[];
+ bdstUsgCd: SelectDataType[];
+ cityCd: SelectDataType[];
+ sggCd: SelectDataType[];
+ rvbsnCd: SelectDataType[];
+ mdmbsnCd: SelectDataType[];
+ lgbsnCd: SelectDataType[];
+ lclgvrnmntCd: EnvPartSelectDataType[];
+ orgwtKndCd: SelectDataType[];
+ yn: SelectDataType[];
+ pplQulity: SelectDataType[];
+ pplLenght: SelectDataType[];
+ dmdUszCd:SelectDataType[]
+ buildingType: {
+ RST:string,
+ RNB:string,
+ HTB:string
+ }
+ ruseMngMtd:SelectDataType[]
+ };
+};
+
+export type comCodeType = comCodeState & comCodeActions;
+
+export const getSggCd = async (set: any) => {
+ const sgg = await getFetch("common", "/addr/sgg");
+ /* const sggCd = sgg.map((item: any) => ({
+ val: item.adstDstrCd,
+ text: item.gugun,
+ })); */
+
+ const sggCd = [
+ { text: "전체", val: '0' },
+ ...sgg
+ .map((item: any) => ({
+ text: item.gugun || '',
+ val: String(item.adstDstrCd) || ''
+ }))
+ ];
+
+ set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ sggCd: sggCd,
+ },
+ }));
+};
+export const getCityCd = async (set: any) => {
+ const city = await getFetch("common", "/addr/city");
+ const cityCd = city.map((item: any) => ({
+ val: item.adstDstrCd,
+ text: item.sido,
+ }));
+ cityCd.unshift({ val: '0', text: '전체' })
+ set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ cityCd: cityCd,
+ },
+ }));
+};
+
+// 권역 API 호출 함수 추가
+export const getRegionCd = async (set: any) => {
+ try {
+ const rvbsn = await getFetch("common", "/addr/sarea");
+ const rvbsnCd = rvbsn.map((item: any) => ({
+ val: item.rvbsnCd,
+ text: item.rvbsn,
+ }));
+ rvbsnCd.unshift({ val: '0', text: '전체' })
+ set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ rvbsnCd: rvbsnCd,
+ },
+ }));
+ } catch (error) {
+ console.error('권역 데이터를 가져오는데 실패했습니다:', error);
+ }
+};
+
+// 중권역 API 호출 함수 추가
+export const getMiddleRegionCd = async (set: any) => {
+ try {
+ const mdmbsn = await getFetch("common", "/addr/midArea");
+ const mdmbsnCd = mdmbsn.map((item: any) => ({
+ val: item.rvbsnCd,
+ text: item.mdmbsn,
+ }));
+ mdmbsnCd.unshift({ val: '0', text: '전체' })
+ set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ mdmbsnCd: mdmbsnCd,
+ },
+ }));
+ } catch (error) {
+ console.error('중권역 데이터를 가져오는데 실패했습니다:', error);
+ }
+};
+
+
+// 단위유역 API 호출 함수 추가
+export const getUnitWaterShedCd = async (set: any) => {
+ try {
+ const lgbsn = await getFetch("common", "/addr/largeArea");
+ const lgbsnCd = lgbsn.map((item: any) => ({
+ val: item.rvbsnCd,
+ text: item.lgbsn,
+ }));
+ lgbsnCd.unshift({ val: '0', text: '전체' })
+ set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ lgbsnCd: lgbsnCd,
+ },
+ }));
+ } catch (error) {
+ console.error('대영역 데이터를 가져오는데 실패했습니다:', error);
+ }
+};
+
+
+
+// 환경청 데이터
+export const getEnvPartCd = async (set: any) => {
+ try {
+ const lclgvrnmnt = await getFetch('common', '/addr/govArea');
+ const lclgvrnmntCd = lclgvrnmnt.map((item: any) => ({
+ val: item.lclgvrnmntCd,
+ text: item.lclgvrnmntNm,
+ adstDliStrCd: item.adstDliStrCd || ''
+
+ }));
+ lclgvrnmntCd.unshift({ val: '0', text: '전체', adstDliStrCd: '' })
+ set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ lclgvrnmntCd: lclgvrnmntCd,
+ },
+ }));
+ } catch (error) {
+ console.error('환경청 데이터를 가져오는데 실패했습니다:', error);
+ }
+};
+
+
+
+export const comCodeStateExport: comCodeState = {
+ code: {
+ isInit: false,
+ rainFcltCd: rainFcltCd,
+ bdstUsgCd: bdstUsgCd,
+ chBuCd: chBuCd,
+ orgwtKndCd: orgwtKndCd,
+ cityCd: [],
+ sggCd: [],
+ rvbsnCd: [],
+ mdmbsnCd: [],
+ lgbsnCd: [],
+ lclgvrnmntCd: [],
+ pplQulity:pplQulity,
+ pplLenght:pplLenght,
+ yn: yn,
+ dmdUszCd:dmdUszCd,
+ buildingType:buildingType,
+ ruseMngMtd:ruseMngMtd,
+ },
+};
+
+export type comCodeActions = {
+ codeInit: () => void;
+};
+
+
+
+
+export const codeActionExport: (set: any) => comCodeActions = (set: any) => {
+ return {
+ codeInit: async () => {
+ const sgg = await getFetch("common", "/addr/sgg");
+
+ const sggCd = sgg.map((item: any) => ({
+ val: item.adstDstrCd,
+ text: item.gugun,
+ }));
+
+ const city = await getFetch("common", "/addr/city");
+ const cityCd = city.map((item: any) => ({
+ val: item.adstDstrCd,
+ text: item.sido,
+ }));
+
+ return set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ sggCd: sggCd,
+ cityCd: cityCd,
+ },
+ }));
+ },
+
+ divCityCd: async (cd: string) => {
+ set((state: comCodeState) => ({
+ code: {
+ ...state.code,
+ sggCd: state.code.sggCd.filter((item) => { return item.val.toString().slice(0, 2) === cd }),
+ },
+ }));
+ },
+ };
+};
diff --git a/apps/wr/app/store/common/searchCode/index.ts b/apps/wr/app/store/common/searchCode/index.ts
new file mode 100644
index 000000000..8f05eca09
--- /dev/null
+++ b/apps/wr/app/store/common/searchCode/index.ts
@@ -0,0 +1,122 @@
+import {
+ fetchType,
+ getFetch,
+ postFectch,
+ putFectch,
+} from "@/components/lib/api";
+import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
+import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
+import type { conCostFeeType, rateFeeType } from "./type";
+export type comFcltState = {
+ searchFclts: pubHasuType;
+ demandCompList: DemandCompType[];
+ dmdIsSucees: string;
+ checkDemand: DemandCompType;
+ constCostRes:conCostFeeType[],
+ rateFeeRes:rateFeeType[],
+
+};
+export type comFcltActions = {
+ getSwtrmtFcltNm: (searchNm: string) => void;
+ getDemandCompList: (searchNm: string, cnt: number) => void;
+ regDemandCompany: (data: DemandCompType) => void;
+ updateDemandCompany: (data: DemandCompType) => void;
+ getConstCostFee: (year: string) => void;
+ getRateFee: (year: string) => void;
+};
+
+export const searchActions: (set: any) => comFcltActions = (set: any) => {
+ return {
+ getSwtrmtFcltNm: async (searchNm: string) => {
+ const fcltNm = await getFetch(
+ "common",
+ `/prcsFclt/info/1/11/${searchNm}`
+ );
+ const searchFclts: pubHasuType[] = fcltNm.map((item: any) => ({
+ bscFctCd: item.bscFctCd,
+ sido: item.sido,
+ gugun: item.gugun,
+ bscFctNm: item.bscFctNm,
+ addr: item.addr,
+ fctCpc: item.fctCpc,
+ }));
+ set((state: comFcltState) => ({
+ ...state,
+ searchFclts: searchFclts,
+ }));
+ },
+ getDemandCompList: async (searchNm: string, cnt: number) => {
+ const coList = await getFetch(
+ fetchType.WR,
+ `/reuseFc/request/${searchNm}/${cnt}`
+ );
+
+ console.log(coList);
+ set((state: comFcltState) => {
+ return (state.demandCompList = [...coList]);
+ });
+ },
+ regDemandCompany: async (data: DemandCompType) => {
+ try {
+ const response = await postFectch(
+ "/reuseFc/request",
+ data,
+ fetchType.WR
+ );
+ let message = "";
+ if (response.status === 200) {
+ message = "success";
+ } else {
+ message = "fail";
+ }
+ set((state: comFcltState) => {
+ state.dmdIsSucees = message;
+ return state;
+ });
+ } catch (err) {
+ console.log(err);
+ }
+ },
+ updateDemandCompany: async (data: DemandCompType) => {
+ try {
+ const response = await putFectch("/reuseFc/request", data);
+
+ let message = "";
+ if (response.status === 200) {
+ message = "success";
+ } else {
+ message = "fail";
+ }
+
+ set((state: comFcltState) => {
+ state.dmdIsSucees = message;
+ return state;
+ });
+ } catch (err) {
+ console.log(err);
+ }
+ },
+ getRateFee: async (year: string) => {
+ try {
+ const url = `/prcsFclt/CstRt/${year}`;
+ const rateFeeRes = await getFetch(fetchType.COMMON, url);
+
+ set((state: comFcltState) => {
+ return state.rateFeeRes = rateFeeRes;;
+ });
+ } catch (e) {
+ console.log(" error ", e);
+ }
+ },getConstCostFee: async (year: string) => {
+ try {
+ const url = `/prcsFclt/CstRuse/${year}`;
+ const constCost = await getFetch(fetchType.COMMON, url);
+ set((state: comFcltState) => {
+ return state.constCostRes = constCost;;
+ });
+ }catch (e) {
+ }
+
+ }
+ };
+};
diff --git a/apps/wr/app/store/common/searchCode/type.tsx b/apps/wr/app/store/common/searchCode/type.tsx
new file mode 100644
index 000000000..0026bd785
--- /dev/null
+++ b/apps/wr/app/store/common/searchCode/type.tsx
@@ -0,0 +1,32 @@
+export type conCostFeeType= {
+ yr: string,
+ fctCpc: string,
+ fctCd: string,
+ stdCost: string
+ }
+
+
+
+ export type rateFeeType = {
+ yr: string,
+ incExpCd: string,
+ stdCost: number,
+ rt: number
+ }
+
+
+
+ export type ContCostMap = {
+ gubun: string;
+ "500": number;
+ "1000": number;
+ "2000": number;
+ "3000": number;
+ "5000": number;
+ "10000": number;
+ "20000": number;
+ "30000": number;
+ "50000": number;
+ "100000": number;
+ [key: string]: any;
+ };
\ No newline at end of file
diff --git a/apps/wr/app/store/common/type/header.tsx b/apps/wr/app/store/common/type/header.tsx
new file mode 100644
index 000000000..f064b7580
--- /dev/null
+++ b/apps/wr/app/store/common/type/header.tsx
@@ -0,0 +1,27 @@
+export type CommonTableProps = {
+ id: string;
+ title: string;
+ upName?: string;
+ upSequnce?: number;
+ row?: number;
+ rowSpan?: number;
+ colSpan?: number;
+ visible?: boolean;
+};
+
+export type TableUpperProps = {
+ id: string;
+ title: string;
+ upName?: string;
+ upSequnce?: number;
+ edit?:boolean;
+ visible?:boolean;
+ rowSpan?: number;
+ colSpan?: number;
+ type?: string;
+ selectData ?:string; // type 이 seelct 일경우 selectarray 정하기 위해
+ row?:number;
+ mergeCell?:boolean // 셀을 합칠경우
+ readonly?:boolean
+ };
+
diff --git a/apps/wr/app/store/index.tsx b/apps/wr/app/store/index.tsx
index 1b759c30e..c1f7fa2fa 100644
--- a/apps/wr/app/store/index.tsx
+++ b/apps/wr/app/store/index.tsx
@@ -1,4 +1,3 @@
-'use client'
import { type ReactNode, createContext, useContext, useRef } from 'react'
import { useStore } from 'zustand'
@@ -15,13 +14,11 @@ export interface StoreProviderProps {
children: ReactNode
}
-export const StoreProvider = ({
+export const StoreProvider = ({
children,
}: StoreProviderProps) => {
- const storeRef = useRef(null)
- if (!storeRef.current) {
- storeRef.current = StoreZus()
- }
+ const storeRef = useRef(StoreZus())
+
return (
{children}
diff --git a/apps/wr/app/store/matDmd/coMatRvw/headList.tsx b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx
new file mode 100644
index 000000000..7b43e4b00
--- /dev/null
+++ b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx
@@ -0,0 +1,199 @@
+import type { CommonTableProps, TableUpperProps } from "../../common/type/header";
+
+
+
+export const coRvwHeadListExport: CommonTableProps[]= [
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ },
+ {
+ id: "dmdCoNm",
+ title: "회사명",
+ visible: true,
+ },
+ {
+ id: "daddr",
+ title: "공장주소",
+ visible: true,
+ },
+ {
+ id: "telno",
+ title: "전화번호",
+ visible: true,
+ },
+ {
+ id: "regDt", //바꾸기
+ title: "신청일자",
+ visible: true,
+ },
+ {
+ id: "state", //바꾸기
+ title: "진행상태",
+ visible: true,
+ },
+];
+
+// id는 다확인해야함
+export const coRvwNodeListExport: CommonTableProps[] = [
+ {
+ id: "ctpv",
+ title: "시도",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sgg",
+ title: "시군구",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "coNm",
+ title: "회사명",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "addr",
+ title: "공장주소",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "telNo",
+ title: "전화번호",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "regDt", //바꾸기
+ title: "신청일자",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "state", //바꾸기
+ title: "진행상태",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+];
+
+export const constCostHeadListExport: CommonTableProps[] = [
+ {
+ id: "gubun",
+ title: "구분",
+ visible: true,
+ },
+ {
+ id: "500",
+ title: "500",
+ visible: true,
+ },
+ {
+ id: "1000",
+ title: "1,000",
+ visible: true,
+ },
+ {
+ id: "2000",
+ title: "2,000",
+ visible: true,
+ },
+ {
+ id: "3000", //바꾸기
+ title: "3,000",
+ visible: true,
+ },
+ {
+ id: "5000", //바꾸기
+ title: "5,000",
+ visible: true,
+ },
+ {
+ id: "10000", //
+ title: "10,000",
+ visible: true,
+ },
+ {
+ id: "20000", //
+ title: "20,000",
+ visible: true,
+ },
+ {
+ id: "30000", //
+ title: "30,000",
+ visible: true,
+ },
+ {
+ id: "50000", //
+ title: "50,000",
+ visible: true,
+ },
+ {
+ id: "100000", //바꾸기
+ title: "100,000",
+ visible: true,
+ },
+];
+
+export const rateFeeHeadListExport: CommonTableProps[] = [
+ {
+ id: "gubun",
+ title: "공사비/구분",
+ visible: true,
+ },
+ {
+ id: "BD",
+ title: "기본조사설계비",
+ visible: true,
+ },
+ {
+ id: "WD",
+ title: "실시설계비",
+ visible: true,
+ },
+ {
+ id: "SE",
+ title: "공사감리비",
+ visible: true,
+ },
+ {
+ id: "CE",
+ title: "시설부대비",
+ visible: true,
+ },
+];
+
+export const usageProcData = [
+ { usage: "청소", process: "총인처리시설+염소소독" },
+ { usage: "화장실용수", process: "총인처리시설+염소소독" },
+ { usage: "세척", process: "총인처리시설+UV소독" },
+ { usage: "살수", process: "총인처리시설+UV소독" },
+ { usage: "조경", process: "총인처리시설+UV소독" },
+ { usage: "농업", process: "총인처리시설+UV소독" },
+ { usage: "하천", process: "총인처리시설+UV소독" },
+ { usage: "지하수", process: "전처리시설+RO" },
+ { usage: "공업", process: "전처리시설+RO" },
+];
diff --git a/apps/wr/app/store/matDmd/coMatRvw/index.tsx b/apps/wr/app/store/matDmd/coMatRvw/index.tsx
new file mode 100644
index 000000000..89836957b
--- /dev/null
+++ b/apps/wr/app/store/matDmd/coMatRvw/index.tsx
@@ -0,0 +1,183 @@
+import { constCostHeadListExport, coRvwHeadListExport, coRvwNodeListExport, rateFeeHeadListExport } from "./headList";
+import type { CommonTableProps } from "../../common/type/header";
+import type { DedMatUpdateType, DmdCoReqType } from "./type";
+import { fetchType, getFetch, putFectch } from "@/components/lib/api";
+import toast from "react-hot-toast/headless";
+
+const coRvwHeadList = coRvwHeadListExport;
+const coRvwNodeList = coRvwNodeListExport;
+const rateFeeHeadList =rateFeeHeadListExport;
+const constCostHeadList=constCostHeadListExport
+export type coRvwState = {
+ coRvw: {
+ isInit: boolean;
+ coMatRvwRes: DmdCoReqType[];
+ coRvwHeadList: CommonTableProps[];
+ coRvwNodeList: CommonTableProps[];
+ rateFeeHeadList: CommonTableProps[];
+ constCostHeadList: CommonTableProps[];
+ };
+};
+
+export const coRvwStateExport: coRvwState = {
+ coRvw: {
+ isInit: false,
+ coMatRvwRes: [],
+ coRvwHeadList: coRvwHeadList,
+ coRvwNodeList: coRvwNodeList,
+ rateFeeHeadList:rateFeeHeadList,
+ constCostHeadList:constCostHeadList
+ },
+};
+
+export type coRvwType = coRvwState & coRvwActions;
+
+type coRvwActions = {
+ coMatRvwInit: (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ ) => void;
+ coMatRvwUpdate: (
+ splyCd: string,
+ dmdCd: string,
+ data: DedMatUpdateType
+ ) => void;
+ coMatRvwSearch: (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string,
+ dmdCoNm: string,
+ ) => void;
+ coMatRvwInqua: (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string
+ ) => void;
+};
+
+const coMatInit = async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+) => {
+ const url = `/reuseFc/request/infoList/sub/${pageNo}/${pageCnt}/${startYear}/${endYear}`;
+ const coMatRvwRes = await getFetch(fetchType.WR, url);
+
+ return coMatRvwRes;
+};
+
+export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => {
+ return {
+ coMatRvwInit: async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ ) => {
+ const coMatRvwRes = await coMatInit(pageNo, pageCnt, startYear, endYear);
+
+ return set((state: coRvwState) => ({
+ ...state,
+ coRvw: {
+ ...state.coRvw,
+ init: false,
+ coMatRvwRes: coMatRvwRes,
+ },
+ }));
+ },
+ coMatRvwUpdate: async (
+ splyCd: string,
+ dmdCd: string,
+ data: DedMatUpdateType
+ ) => {
+ try {
+ const isUpdate = await putFectch(
+ `/reuseFc/request/cst/${splyCd}/${dmdCd}`,
+ data
+ );
+
+ const coMatRvwRes = coMatInit(
+ 1,
+ 10,
+ new Date().getFullYear().toString(),
+ new Date().getFullYear().toString(),
+ );
+ return set((state: coRvwState) => ({
+ ...state,
+ coRvw: {
+ ...state.coRvw,
+ init: false,
+ coMatRvwRes: coMatRvwRes,
+ },
+ }));
+ } catch (e) {
+ toast.error("매칭 검토 저장 오류입니다.");
+ }
+ },
+ coMatRvwSearch: async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string,
+ dmdCoNm: string,
+ ) => {
+ let url = `/reuseFc/request/infoList/sub/${pageNo}/${pageCnt}/${startYear}/${endYear}`;
+
+ if (sggCd.length > 0) {
+ url += `/${sggCd}`;
+ } else {
+ url += `/0`;
+ }
+ if (dmdCoNm?.length > 0) {
+ url += `/${dmdCoNm}`;
+ } else {
+ url += `/0`;
+ }
+
+ console.log(' url ', url)
+ const coMatRvwRes = await getFetch(fetchType.WR, url);
+
+ return set((state: coRvwState) => ({
+ ...state,
+ coRvw: {
+ ...state.coRvw,
+ coMatRvwRes: coMatRvwRes,
+ },
+ }));
+ },
+ coMatRvwInqua: async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string
+ ) => {
+ try {
+ let url = `/reuseFc/request/infoList/sub/${pageNo}/${pageCnt}/${startYear}/${endYear}`;
+ if (sggCd.length > 0) {
+ url += `/${sggCd}/0`;
+ }else if(sggCd ==='0'){
+ url += `/0/0`;
+ }
+ const coMatRvwRes = await getFetch(fetchType.WR, url);
+ return set((state: coRvwState) => ({
+ ...state,
+ coRvw: {
+ ...state.coRvw,
+ coMatRvwRes: coMatRvwRes,
+ },
+ }));
+ } catch (e) {
+ console.log(" error ", e);
+ }
+ }
+ };
+};
diff --git a/apps/wr/app/store/matDmd/coMatRvw/type.tsx b/apps/wr/app/store/matDmd/coMatRvw/type.tsx
new file mode 100644
index 000000000..9f146c0fb
--- /dev/null
+++ b/apps/wr/app/store/matDmd/coMatRvw/type.tsx
@@ -0,0 +1,173 @@
+import { z } from "zod";
+
+ const DemandInfoSchema = z.object({
+ dmdInfoSn: z.number(),
+ dmdInfoFk: z.string(),
+ dmndTmng: z.coerce.date(),
+ dmndQty: z.number(),
+ wntUntprc: z.number(),
+ grssClfg: z.number(),
+ combResdch: z.number(),
+ trbt: z.number(),
+ blgcOxygDmndQnt: z.number(),
+ smll: z.number(),
+ crmty: z.number().nullish(),
+ tn: z.number(),
+ tph: z.number(),
+ ph: z.number(),
+ clIonQnt: z.number(),
+ cdtnv: z.number(),
+ rmrk: z.string(),
+ useUsgCd: z.string(),
+ mtchnCmptnYmd: z.string().nullish(),
+ rvwCmptnYmd: z.string().nullish()
+ });
+
+ const DemandMatchingSchema = z.object({
+ dmdInfoFk: z.string().nullish(),
+ splyFcltFk: z.string().nullish(),
+ splyFcltFlg: z.string().nullish(),
+ pbnstRuseFcltBizFk: z.number().nullish(),
+ splyBgngDay: z.coerce.date().nullish(),
+ splyEndDay: z.coerce.date().nullish(),
+ splyCpct: z.number().nullish(),
+ splyFmYn: z.string().nullish(),
+ useUsgCd: z.string().nullish(),
+ dmdInfoSn: z.number().nullish(),
+ splyCndtList:z.array(z.string().nullish() ).nullish()
+ });
+
+ const DemandCoSchema = z.object({
+ dmdInfoPk: z.string(),
+ dmdCoNm: z.string(),
+ ctpvCd: z.string(),
+ sggCd: z.string(),
+ daddr: z.string(),
+ splyBgngDay: z.coerce.date(),
+ splyEndDay: z.coerce.date(),
+ splyCpct: z.number(),
+ splyFmYn: z.string().nullish(),
+ telno: z.string(),
+ useUsgCd: z.string().nullish(),
+ regDt: z.coerce.date().nullish(),
+ rgtr: z.string().nullish(),
+ mdfcnDt: z.coerce.date().nullish(),
+ mdfr: z.string().nullish(),
+ dmdAplyPswd: z.string(),
+ demandInfo: z.array(DemandInfoSchema.nullish()).nullish(), // 안쓰는 거임
+ demandMatchings: z.array(DemandMatchingSchema.nullish()).nullish()// 안쓰는 거임
+ });
+
+ const DemandCstSchema = z.object({
+ dmdInfoSn: z.number(),
+ usgPrcsProcs: z.string().nullish(),
+ cstrnCst: z.number(),
+ fcltSbsdCstrnCst: z.number(),
+ prcsFcltCpctCstrnCst: z.number()
+ });
+
+ export const DmdCoReqSchema = z.object({
+ cityText:z.string().nullish(),
+ sggText:z.string().nullish(),
+ dmdInfoSn: z.number(),
+ dmdInfoFk: z.string(),
+ dmndTmng: z.coerce.date(),
+ dmndQty: z.number(),
+ wntUntprc: z.number().nullish(),
+ grssClfg: z.number().nullish(),
+ combResdch: z.number().nullish(),
+ trbt: z.number().nullish(),
+ blgcOxygDmndQnt: z.number(),
+ smll: z.number().nullish(),
+ crmty: z.number().nullish(),
+ tn: z.number().nullish(),
+ tph: z.number().nullish(),
+ ph: z.number().nullish(),
+ clIonQnt: z.number().nullish(),
+ cdtnv: z.number(),
+ rmrk: z.string().nullish(),
+ useUsgCd: z.string().nullish(),
+ mtchnCmptnYmd: z.string().nullish(),
+ rvwCmptnYmd: z.string().nullish(),
+ demandCo: DemandCoSchema.nullish(),
+ demandMatching: DemandMatchingSchema.nullish(),
+ demandCst: DemandCstSchema,
+ ruseUtztnFcltNm:z.string().nullish(),
+ totalConstCost:z.number().nullish(),
+
+ });
+
+
+export type DmdCoReqType = z.infer;
+export type DmdMatTableType = {
+ cityText:string,
+ sggText:string,
+ dmdCoNm:string,
+ daddr:string,
+ telno:string,
+ regDt:string,
+ splyFcltFlg:string
+}
+
+
+export type DedMatUpdateType =
+{
+ dmdInfoSn: number;
+ usgPrcsProcs: string;
+ cstrnCst: number;
+ fcltSbsdCstrnCst: number;
+ prcsFcltCpctCstrnCst: number;
+ rgtr: string;
+}
+
+
+export type RvwHistTableType = {
+ cityText:string,
+ sggText:string,
+ dmdCoNm:string,
+ daddr:string,
+ telno:string,
+ regDt:string,
+ rvwCmptnYmd:string,
+ mtchnCmptnYmd:string,
+ ruseUtztnFcltNm:string,
+ dmndQty:string,
+ useUsgCd:string,
+ splyFcltFlg:string
+ completeYn:boolean
+ dmdInfoSn :string
+
+}
+
+export type RvwHistTableType = {
+ cityText:string,
+ sggText:string,
+ dmdCoNm:string,
+ daddr:string,
+ telno:string,
+ regDt:string,
+ rvwCmptnYmd:string,
+ mtchnCmptnYmd:string,
+ ruseUtztnFcltNm:string,
+ dmndQty:string,
+ useUsgCd:string,
+ splyFcltFlg:string
+ completeYn:boolean
+ dmdInfoSn :string
+
+}
+
+
+
+export type conCostFeeType= {
+ yr: string,
+ fctCpc: string,
+ fctCd: string,
+ stdCost: string
+}
+export type rateFeeType = {
+ yr: string,
+ incExpCd: string,
+ stdCost: number,
+ rt: number
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/coSttn/excel.tsx b/apps/wr/app/store/matDmd/coSttn/excel.tsx
new file mode 100644
index 000000000..39d669664
--- /dev/null
+++ b/apps/wr/app/store/matDmd/coSttn/excel.tsx
@@ -0,0 +1,17 @@
+import type { customCoSttnBdst } from ".";
+
+export const excelCoSttnParsing = (data: customCoSttnBdst[]): string[][] => {
+ const excelExportData: string[][] = [];
+
+ data.forEach((item) => {
+ excelExportData.push([
+ String(item.ctpvCd),
+ String(item.sggCd),
+ item.dmdCoNm ?? "",
+ item.daddr ?? "",
+ String(item.dmdInfoPk ?? ""),
+ item.telno ?? ""
+ ]);
+ });
+ return excelExportData;
+};
diff --git a/apps/wr/app/store/matDmd/coSttn/headList.tsx b/apps/wr/app/store/matDmd/coSttn/headList.tsx
new file mode 100644
index 000000000..80fed0d76
--- /dev/null
+++ b/apps/wr/app/store/matDmd/coSttn/headList.tsx
@@ -0,0 +1,98 @@
+import type { CommonTableProps } from "@/app/store/common/type/header";
+import { z } from "zod";
+
+export const sttnHeadListType = z.array(
+ z.object({
+ id: z.string(),
+ title: z.string(),
+ visible: z.boolean(),
+ })
+);
+
+export const coRegExcel = z.object({
+ file: z.any()
+});
+
+export const coSttHeadListExport: z.infer = [
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ },
+ {
+ id: "dmdCoNm",
+ title: "회사명",
+ visible: true,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ },
+ {
+ id: "dmdInfoPk",
+ title: "사업자번호",
+ visible: true,
+ },
+ {
+ id: "telno",
+ title: "전화번호",
+ visible: true,
+ },
+];
+
+export const coSttNodeListExport: CommonTableProps[] = [
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "dmdCoNm",
+ title: "회사명",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "dmdInfoPk",
+ title: "사업자번호",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "telno",
+ title: "전화번호",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+];
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/coSttn/index.tsx b/apps/wr/app/store/matDmd/coSttn/index.tsx
new file mode 100644
index 000000000..0de37bbfc
--- /dev/null
+++ b/apps/wr/app/store/matDmd/coSttn/index.tsx
@@ -0,0 +1,123 @@
+import type { CommonTableProps } from "@/app/store/common/type/header";
+import { fetchType, getFetch, getFetchWithCount } from "@/components/lib/api";
+import { coSttHeadListExport, coSttNodeListExport } from "./headList";
+import { excelCoSttnParsing } from "./excel";
+import type { DemandCompType } from "@common/business_components/ui";
+
+// 테이블 헤드 리스트
+const coSttNodeList = coSttNodeListExport;
+const coSttHeadList = coSttHeadListExport;
+const coSttnRes: DemandCompType[] = [];
+
+
+export type coSttnState = {
+ coSttn: {
+ coSttnRes: DemandCompType[];
+ coSttHeadList: CommonTableProps[];
+ coSttNodeList: CommonTableProps[];
+ excelList: [];
+ isInit: boolean;
+ coSttnResCount: number;
+ };
+};
+
+type coSttnActions = {
+ coSttnInit:(pageNo:string, pageCnt:string, con: string) => void;
+ coSttnSearch: (pageNo:string, pageCnt:string, con: string) => void;
+ coSttnTxtSearch:(pageNo:string, pageCnt:string, con: string,txt:string) => void;
+};
+
+export type coSttnType = coSttnState & coSttnActions;
+
+export const coSttnStateExport: coSttnState = {
+ coSttn: {
+ coSttHeadList: coSttHeadList,
+ coSttNodeList: coSttNodeList,
+ coSttnRes: coSttnRes,
+ excelList: [],
+ isInit: false,
+ coSttnResCount: 0,
+ },
+};
+
+
+export const coSttnActionsExport: (set: any) => coSttnActions = (
+ set: any
+) => {
+ return {
+ coSttnInit: async (pageNo:string, pageCnt:string, con: string) => {
+ try {
+
+ const coSttnRes = await getFetchWithCount(
+ fetchType.WR,
+ `/reuseFc/request/${pageNo}/${pageCnt}/${con}`
+ );
+
+ set((state: coSttnState) => {
+ return {
+ ...state,
+ coSttn: {
+ ...state.coSttn,
+ coSttnRes: coSttnRes.data,
+ isInit: false,
+ coSttnResCount: coSttnRes.count,
+ },
+ };
+ });
+ } catch (e) {
+ console.log(e)
+ }
+ },
+ coSttnSearch: async (pageNo:string, pageCnt:string, con: string) => {
+ try {
+ const coSttnRes = await getFetchWithCount(
+ fetchType.WR,
+ `/reuseFc/request/${pageNo}/${pageCnt}/${con}`
+ );
+ if (Number(pageCnt) >= 10000) {
+ const coExcel = excelCoSttnParsing(coSttnRes.data);
+ set((state: coSttnState) => {
+ return {
+ ...state,
+ coSttn: {
+ ...state.coSttn,
+ excelList: coExcel,
+ isInit: false,
+ },
+ };
+ });
+ } else
+ set((state: coSttnState) => {
+ return {
+ ...state,
+ coSttn: {
+ ...state.coSttn,
+ coSttnRes: coSttnRes.data,
+ isInit: false,
+ coSttnResCount : coSttnRes.count,
+ },
+ };
+ });
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ },
+ coSttnTxtSearch: async (pageNo:string, pageCnt:string, con: string, txt: string) => {
+ try {
+ const coSttnRes = await getFetch(
+ fetchType.WR,
+ `/reuseFc/request/${pageNo}/${pageCnt}/${con}/${txt}`)
+ set((state: coSttnState) => {
+ return {
+ ...state,
+ coSttn: {
+ ...state.coSttn,
+ coSttnRes: coSttnRes,
+ isInit: false,
+ }}})
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/drgtSttn/headList.tsx b/apps/wr/app/store/matDmd/drgtSttn/headList.tsx
new file mode 100644
index 000000000..40eae47e3
--- /dev/null
+++ b/apps/wr/app/store/matDmd/drgtSttn/headList.tsx
@@ -0,0 +1,102 @@
+import type { CommonTableProps } from "../../common/type/header";
+
+export const drgtHeadListExport: CommonTableProps[] = [
+ {
+ id: "ctpvCd",
+ title: "시도",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggCd",
+ title: "시군구",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "haengjung",
+ title: "행정동",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "normal",
+ title: "정상(횟수)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "attention",
+ title: "관심(횟수)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "caution",
+ title: "주의(횟수)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "warning",
+ title: "관심+주의(횟수)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "ranking",
+ title: "가뭄순위",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+];
+
+export const drgtDetailHeadListExport: CommonTableProps[] = [
+ {
+ id: "year",
+ title: "년",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "month",
+ title: "월",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },{
+ id: "day",
+ title: "일",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "state",
+ title: "가뭄상태",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+]
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/drgtSttn/index.tsx b/apps/wr/app/store/matDmd/drgtSttn/index.tsx
new file mode 100644
index 000000000..edbbc2f28
--- /dev/null
+++ b/apps/wr/app/store/matDmd/drgtSttn/index.tsx
@@ -0,0 +1,27 @@
+import type { CommonTableProps } from "../../common/type/header";
+import { drgtHeadListExport } from "./headList";
+
+const drgtHeadList = drgtHeadListExport;
+
+export type drgtState = {
+ drgt:{
+ drgtHeadList: CommonTableProps[];
+ }
+}
+
+type drgtActions = {
+};
+
+export type drgtType = drgtState & drgtActions;
+
+export const drgtStateExport: drgtState = {
+ drgt: {
+ drgtHeadList: drgtHeadList,
+ }
+}
+
+export const drgtActionsExport: (set: any) => drgtActions = (
+ set: any
+) => {
+ return {};
+};
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/index.tsx b/apps/wr/app/store/matDmd/index.tsx
index 2ed933348..ed8ecd919 100644
--- a/apps/wr/app/store/matDmd/index.tsx
+++ b/apps/wr/app/store/matDmd/index.tsx
@@ -1,4 +1,4 @@
-import type { selectArray } from "../rainReuseFacilityInsert";
+import type { SelectDataType } from "@common/business_components/ui";
@@ -23,10 +23,10 @@ const selectSgg = [
export type matDmdState ={ dmd:{
isInit: boolean;
- selectSido:selectArray[];
- selectSgg:selectArray[];
- selectUsg:selectArray[];
- selectYN:selectArray[];
+ selectSido:SelectDataType[];
+ selectSgg:SelectDataType[];
+ selectUsg:SelectDataType[];
+ selectYN:SelectDataType[];
}}
type matDmdActions = {
decrementList: () => void
diff --git a/apps/wr/app/store/matDmd/ldrmntCoSttn/excel.tsx b/apps/wr/app/store/matDmd/ldrmntCoSttn/excel.tsx
new file mode 100644
index 000000000..dc0601127
--- /dev/null
+++ b/apps/wr/app/store/matDmd/ldrmntCoSttn/excel.tsx
@@ -0,0 +1,75 @@
+import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
+
+type nameMap = {
+ [key: string]: string;
+}
+
+export const names: nameMap = {
+ "시도": "ctpvCd",
+ "시군구명": "sggCd",
+ "관리기관": "mngInst",
+ "회사명": "dmdCoNm",
+ "공장구분": "fctrySe",
+ "단지명": "cmpxNm",
+ "설립구분": "fndnSe",
+ "입주형태": "mvnShp",
+ "보유구분": "hldSe",
+ "최초승인일": "frstAprvYmd",
+ "최초등록일": "frstRegYmd",
+ "등록구분": "regSe",
+ "등록일": "regYmd",
+ "전화번호": "telno",
+ "남자종업원": "maleEmpCnt",
+ "여자종업원": "fmaleEmpCnt",
+ "외국인남자종업원": "frgnrMaleEmpCnt",
+ "외국인여자종업원": "frgnrFmaleEmpCnt",
+ "종업원합계": "totalEmpCnt",
+ "생산품": "prdctnItem",
+ "원자재": "splyMtrl",
+ "공장규모": "fctryScl",
+ "용도지역": "usgRgn",
+ "지목": "ldcg",
+ "용지면적": "usgRgnArea",
+ "제조시설면적": "mnftrFcltArea",
+ "부대시설면적": "sbsdFcltArea",
+ "건축면적": "archArea",
+ "지식산업센터명": "knwlIndstCntrNm",
+ "대표업종": "rprsTpbiz",
+ "업종명": "tpbizNm",
+ "업종코드": "tpbizCd",
+ "차수": "cycl",
+ "법인주소": "corpAddr",
+ "필지수": "esntlIdx",
+ "공장주소": "fctryAddr",
+ "공장주소_지번": "fctryLotnoAddr",
+ "공장관리번호": "fctryMngNo",
+}
+
+
+export const excelPbnstSttnParsing = (data: any[]): string[][] => {
+
+ const excelExportData: string[][] = [];
+
+ data.forEach((item) => {
+ excelExportData.push([
+ item.rvbsn,
+ String(item.lgbsn),
+ item.mdmbsn ?? "",
+ item.rgnNm ?? "",
+ String(item.sido ?? ""),
+ String(item.gugun ?? ""),
+ String(item.bscFctNm ?? ""),
+ String(item.efflWqltStndrdNm ?? ""),
+ String(item.fctCpc ?? ""),
+ String(item.tel ?? ""),
+ String(item.ruseUtztnFcltNm ?? ""),
+ String(item.fcltCpct ?? ""),
+ String(item.splyExtraCpct ?? ""),
+ String(item.ruseCpct ?? ""),
+ String(item.usageTotal ?? ""),
+ String(item.inUsage ?? ""),
+ String(item.outUsage ?? ""),
+ ])
+ })
+ return excelExportData;
+};
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/ldrmntCoSttn/headList.tsx b/apps/wr/app/store/matDmd/ldrmntCoSttn/headList.tsx
new file mode 100644
index 000000000..7a1695039
--- /dev/null
+++ b/apps/wr/app/store/matDmd/ldrmntCoSttn/headList.tsx
@@ -0,0 +1,404 @@
+import { z } from "zod";
+import type { CommonTableProps } from "../../common/type/header";
+import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
+
+export const ldrmntZod = z.object({
+ fctryMngSn: z.string().default(''),
+ ctpvCd: z.string().default(''),
+ sggCd: z.string().default(''),
+ mngInstNm: z.string().default('').nullish(),
+ dmdCoNm: z.string().default(''),
+ fctrySe: z.string().default(''),
+ cmpxNm: z.string().default(''),
+ fndnSe: z.string().default(''),
+ mvnShp: z.string().default(''),
+ hldSe: z.string().default(''),
+ frstAprvYmd: z.string().default(''),
+ frstRegYmd: z.string().default(''),
+ regSe: z.string().default(''),
+ regYmd: z.string().default(''),
+ telno: z.string().default(''),
+ maleEmpCnt: z.number().default(0),
+ fmaleEmpCnt: z.number().default(0),
+ frgnrMaleEmpCnt: z.number().default(0),
+ frgnrFmaleEmpCnt: z.number().default(0),
+ totalEmpCnt: z.number().default(0),
+ prdctnItem: z.string().default(''),
+ splyMtrl: z.string().default(''),
+ fctryScl: z.string().default(''),
+ usgRgn: z.string().default(''),
+ ldcg: z.string().default(''),
+ usgRgnArea: z.number().default(0),
+ mnftrFcltArea: z.number().default(0),
+ sbsdFcltArea: z.number().default(0),
+ archArea: z.number().default(0),
+ knwlIndstCntrNm: z.string().default(''),
+ rprsTpbiz: z.string().default(''),
+ tpbizNm: z.string().default(''),
+ tpbizCd: z.string().default(''),
+ cycl: z.number().default(0),
+ corpAddr: z.string().default(''),
+ esntlIdx: z.number().default(0),
+ fctryAddr: z.string().default(''),
+ fctryLotnoAddr: z.string().default(''),
+ fctryMngNo: z.string().default(''),
+ rgtr:z.string().default(TEST_UUID).nullish()
+})
+
+export const ldrmntHeadListExport: CommonTableProps[] = [
+ {
+ id: "ctpvCd",
+ title: "시도",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggCd",
+ title: "시군구",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "dmdCoNm",
+ title: "회사명",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fctryAddr",
+ title: "공장주소",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fctryMngNo",
+ title: "공장관리번호",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "telno",
+ title: "전화번호",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+]
+
+export const ldrmntNodeListExport: CommonTableProps[] = [
+ {
+ id: "ctpvCd",
+ title: "시도",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggCd",
+ title: "시군구",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "mngInstNm",
+ title: "관리기관",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "dmdCoNm",
+ title: "회사명",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fctrySe",
+ title: "공장구분",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "cmpxNm",
+ title: "단지명",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fndnSe",
+ title: "설립구분",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "mvnShp",
+ title: "입주형태",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "hldSe",
+ title: "보유구분",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "frstAprvYmd",
+ title: "최초승인일",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "frstRegYmd",
+ title: "최초등록일",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "regSe",
+ title: "등록구분",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "regYmd",
+ title: "등록일",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "telno",
+ title: "전화번호",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "maleEmpCnt",
+ title: "남자종업원",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fmaleEmpCnt",
+ title: "여자종업원",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "frgnrMaleEmpCnt",
+ title: "외국인남자종업원",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "frgnrFmaleEmpCnt",
+ title: "외국인여자종업원",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "totalEmpCnt",
+ title: "종업원합계",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "prdctnItem",
+ title: "생산품",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "splyMtrl",
+ title: "원자재",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fctryScl",
+ title: "공장규모",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "usgRgn",
+ title: "용도지역",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "ldcg",
+ title: "지목",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "usgRgnArea",
+ title: "용지면적",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "mnftrFcltArea",
+ title: "제조시설면적",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sbsdFcltArea",
+ title: "부대시설면적",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "archArea",
+ title: "건축면적",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "knwlIndstCntrNm",
+ title: "지식산업센터명",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "rprsTpbiz",
+ title: "대표업종",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "tpbizNm",
+ title: "업종명",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "tpbizCd",
+ title: "업종코드",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "cycl",
+ title: "차수",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "corpAddr",
+ title: "법인주소",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "esntlIdx",
+ title: "필지수",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fctryAddr",
+ title: "공장주소",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fctryLotnoAddr",
+ title: "공장주소_지번",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fctryMngNo",
+ title: "공장관리번호",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+];
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/ldrmntCoSttn/index.tsx b/apps/wr/app/store/matDmd/ldrmntCoSttn/index.tsx
new file mode 100644
index 000000000..d1176528a
--- /dev/null
+++ b/apps/wr/app/store/matDmd/ldrmntCoSttn/index.tsx
@@ -0,0 +1,177 @@
+import type { CommonTableProps } from "@/app/store/common/type/header";
+import { deleteFectch, fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
+import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
+import { z } from "zod";
+import { ldrmntHeadListExport, ldrmntNodeListExport, ldrmntZod } from "./headList";
+import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
+
+
+
+// 테이블 헤드 리스트
+const ldrmntHeadList = ldrmntHeadListExport;
+const ldrmntNodeList = ldrmntNodeListExport;
+
+export type customLdrmnt = z.infer;
+
+const ldrmntRes: customLdrmnt[] = [];
+
+export type ldrmntState = {
+ ldrmnt: {
+ ldrmntHeadList: CommonTableProps[];
+ ldrmntNodeList: CommonTableProps[];
+ excelList: ExcelType[];
+ isInit: boolean;
+ ldrmntRes: customLdrmnt[];
+ };
+};
+
+type ExcelType = {
+ [key: string]: string | number | undefined;
+};
+
+const excelDownList: ExcelType[] = [];
+
+type ldrmntActions = {
+ ldrmntRegData: (data: any[]) => void,
+ ldrmntInit: (con: string) => void
+ ldrmntSearch: (page: number, sggCd: string, coNm: string) => void;
+ ldrmntUpdate: (ldrmntRes: customLdrmnt) => void;
+ ldrmntDelete: () => void;
+};
+
+export type ldrmntType = ldrmntState & ldrmntActions;
+
+export const ldrmntStateExport: ldrmntState = {
+ ldrmnt: {
+ ldrmntHeadList: ldrmntHeadList,
+ ldrmntNodeList: ldrmntNodeList,
+ excelList: [],
+ isInit: false,
+ ldrmntRes: ldrmntRes,
+ },
+};
+
+export const ldrmntActionsExport: (set: any) => ldrmntActions = (
+ set: any
+) => {
+ return {
+ ldrmntInit: async (con: string) => {
+ try {
+ const ldrmntRes = await getFetch(
+ fetchType.WR,
+ `/reuseFc/request/temp/1/20/${con}`
+ );
+ set((state: ldrmntState) => {
+ return {
+ ...state,
+ ldrmnt: {
+ ...state.ldrmnt,
+ ldrmntRes: ldrmntRes,
+ isInit: false,
+ },
+ }
+ });
+ } catch (e) {
+ console.log(e)
+ }
+ },
+ ldrmntRegData: async (data) => {
+ try {
+ const response = await postFectch(
+ "/reuseFc/request/temp",
+ data,
+ fetchType.WR
+ );
+
+ console.log('response ', response)
+
+ if (response.status === 200) {
+ ToastFormUi({
+ body: "잠재수요처 등록이 완료되었습니다. ",
+ title: "잠재수요처 등록",
+ });
+
+ }
+ } catch (e) {
+ console.log(e)
+ ToastFormUi({
+ body: "잠재수요처 등록이 실패하였습니다. ",
+ title: "잠재수요처 등록",
+ });
+
+ }
+ },
+ ldrmntSearch: async (page: number, sggCd: string, coNm: string) => {
+ let searchUrl = "";
+
+ if (sggCd !== "") {
+ if (coNm !== "") {
+ searchUrl = `/reuseFc/request/temp/${page}/20/${sggCd}/${coNm}`;
+ } else {
+ searchUrl = `/reuseFc/request/temp/${page}/20/${sggCd}`;
+ }
+ }
+
+ try {
+ const ldrmntRes = await getFetch(
+ fetchType.WR,
+ searchUrl
+ );
+
+ ldrmntRes.forEach((item: customLdrmnt) => {
+ excelDownList.push({
+ ctpvCd: item.ctpvCd,
+ sggCd: item.sggCd,
+ dmdCoNm: item.dmdCoNm,
+ fctryAddr: item.fctryAddr,
+ fctryMngNo: item.fctryMngNo,
+ telno: item.telno,
+ })
+ })
+
+ set((state: ldrmntState) => {
+ return {
+ ...state,
+ ldrmnt: {
+ ...state.ldrmnt,
+ ldrmntRes: ldrmntRes,
+ excelList: excelDownList,
+ },
+ }
+ })
+ } catch (e) {
+ console.log(e)
+ }
+ },
+ ldrmntUpdate: async (ldrmntRes: customLdrmnt) => {
+ try {
+ ldrmntRes.rgtr = TEST_UUID;
+ const response = await putFectch(
+ `/reuseFc/request/temp`,
+ ldrmntRes
+ );
+
+ return set((state: ldrmntState) => ({
+ ...state,
+ ldrmnt: {
+ ...state.ldrmnt,
+ ldrmntRes: ldrmntRes,
+ },
+ }));
+
+ } catch (error) {
+ console.error("Error ldrmntUpdate:", error);
+ }
+ },
+ ldrmntDelete: async () => {
+ try {
+ const response = await deleteFectch(
+ `/reuseFc/request/temp`,
+ );
+
+ } catch (error) {
+ console.error("Error ldrmntDelete:", error);
+ }
+ },
+ }
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/matDmd/ruseCaseMng/headList.tsx b/apps/wr/app/store/matDmd/ruseCaseMng/headList.tsx
new file mode 100644
index 000000000..125866601
--- /dev/null
+++ b/apps/wr/app/store/matDmd/ruseCaseMng/headList.tsx
@@ -0,0 +1,355 @@
+import type { SelectDataType } from "@common/business_components/ui";
+import type { TableUpperProps } from "../../common/type/header";
+
+//★☆★☆ 여기서부터 수정하기 ★☆★☆
+export const ruseCaseHeadListExport: TableUpperProps[] = [
+ {
+ id: "a",
+ title: "사업명",
+ visible: true,
+ row: 0,
+ rowSpan: 2,
+ },
+ {
+ id: "b",
+ title: "사업기간",
+ visible: true,
+ row: 0,
+ rowSpan: 2,
+ },
+ {
+ id: "c",
+ title: "공급처",
+ visible: true,
+ row: 0,
+ colSpan: 3,
+ },
+ {
+ id: "d",
+ title: "시설종류",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "e",
+ title: "공급처명",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "f",
+ title: "시설용량(m³/일)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "g",
+ title: "수요처",
+ visible: true,
+ row: 0,
+ colSpan: 2,
+ },
+ {
+ id: "h",
+ title: "수요처명",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "i",
+ title: "주소",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "q",
+ title: "재이용시설",
+ visible: true,
+ row: 0,
+ colSpan: 5,
+ },
+ {
+ id: "q2",
+ title: "시설용량(m³/일)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "q3",
+ title: "관로(km)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "q4",
+ title: "용도",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "q5",
+ title: "공급량(m³/일)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "q6",
+ title: "처리공법",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k",
+ title: "보증수질",
+ visible: true,
+ row: 0,
+ colSpan: 13,
+ },
+ {
+ id: "k1",
+ title: "용도별",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k2",
+ title: "총대장균군수(개/100ml)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k3",
+ title: "결합잔류염소(mg/L)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k4",
+ title: "탁도(NTU)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k5",
+ title: "생물학적산소요구량(BOD)(mg/L)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k6",
+ title: "냄새",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k7",
+ title: "색도",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k8",
+ title: "총질소(T-N)(mg/L)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k9",
+ title: "총인(T-P)(mg/L)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k10",
+ title: "수소이온농도(PH)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k11",
+ title: "수소이온농도(PH)",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k12",
+ title: "전기전도도(㎲/cm",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "k13",
+ title: "비고",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h",
+ title: "소요사업비(백만원)",
+ visible: true,
+ row: 0,
+ colSpan: 14,
+ },
+ {
+ id: "h1",
+ title: "총",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h2",
+ title: "토목재이용시설",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h3",
+ title: "토목관로",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h4",
+ title: "건축",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h5",
+ title: "기계",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h6",
+ title: "전기・계측",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h7",
+ title: "GIS・DB",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h8",
+ title: "CCTV",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h9",
+ title: "시공및준공",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h10",
+ title: "페기물",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h11",
+ title: "설계비",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h12",
+ title: "감리비",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h13",
+ title: "시설부대비",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "h14",
+ title: "기타",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "i",
+ title: "자원조달계획(백만원)",
+ visible: true,
+ row: 0,
+ colSpan: 4,
+ },
+ {
+ id: "i1",
+ title: "총",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "i2",
+ title: "국비",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "i3",
+ title: "지방비",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "i4",
+ title: "원인자부담",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "j",
+ title: "사업비정산(백만원)",
+ visible: true,
+ row: 0,
+ colSpan: 5,
+ },
+ {
+ id: "j1",
+ title: "총",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "j2",
+ title: "국비",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "j3",
+ title: "지방비",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "j4",
+ title: "원인자부담",
+ visible: true,
+ row: 1,
+ },
+ {
+ id: "j5",
+ title: "국고비율",
+ visible: true,
+ row: 1,
+ },
+];
+
+export const ruseUtzType: SelectDataType[] = [
+ { text: "조경용수", val: "조경용수" },
+ { text: "청소화장실용수", val: "청소화장실용수" },
+ { text: "세척살수용수", val: "세척살수용수" },
+ { text: "농업용수", val: "농업용수" },
+ { text: "공업용수", val: "공업용수" },
+ { text: "친수용수", val: "친수용수" },
+ { text: "기타", val: "기타" },
+];
diff --git a/apps/wr/app/store/matDmd/ruseCaseMng/index.tsx b/apps/wr/app/store/matDmd/ruseCaseMng/index.tsx
new file mode 100644
index 000000000..c54b0db1a
--- /dev/null
+++ b/apps/wr/app/store/matDmd/ruseCaseMng/index.tsx
@@ -0,0 +1,24 @@
+import type { TableUpperProps } from "../../common/type/header";
+import { ruseCaseHeadListExport } from "./headList";
+
+export type ruseCaseState = {
+ ruseCase: {
+ ruseHeadList:TableUpperProps[];
+ };
+ };
+type ruseCaseActions = {
+};
+export type ruseCaseType = ruseCaseState & ruseCaseActions;
+
+export const ruseCaseStateExport: ruseCaseState = {
+ ruseCase: {
+ ruseHeadList:ruseCaseHeadListExport,
+ },
+};
+export const ruseCaseActionsExport: (set: any) => ruseCaseActions = (
+ set: any
+) => {
+ return {
+
+ };
+};
diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx
new file mode 100644
index 000000000..90c793c2f
--- /dev/null
+++ b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx
@@ -0,0 +1,71 @@
+import type { TableUpperProps } from "../../common/type/header";
+
+
+export const ruseHstryHeadListExport:TableUpperProps[]= [
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ },
+ {
+ id: "dmdCoNm",
+ title: "회사명",
+ visible: true,
+ },
+ {
+ id: "daddr",
+ title: "공장주소",
+ visible: true,
+ },
+ {
+ id: "telno",
+ title: "전화번호",
+ visible: true,
+ },
+ {
+ id: "regDt", //바꾸기
+ title: "신청일자",
+ visible: true,
+ },
+ {
+ id: "rvwCmptnYmd", //바꾸기
+ title: "검토일자",
+ visible: true,
+ },
+ {
+ id: "mtchnCmptnYmd", //바꾸기
+ title: "매칭 완료일자",
+ visible: true,
+ },
+ {
+ id: "ruseUtztnFcltNm", //바꾸기
+ title: "공급처",
+ visible: true,
+ },
+ {
+ id: "dmndQty", //바꾸기
+ title: "요구수량(M3/d)",
+ visible: true,
+ },
+ {
+ id: "useUsgCd", //바꾸기
+ title: "사용용도",
+ visible: true,
+ },
+ {
+ id: "splyFcltFlg", //바꾸기
+ title: "진행상태",
+ visible: true,
+ },
+ {
+ id: "completeYn", //바꾸기
+ title: "매칭완료 여부",
+ visible: true,
+ },
+];
+
diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx
new file mode 100644
index 000000000..3338bc467
--- /dev/null
+++ b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx
@@ -0,0 +1,237 @@
+import type { z } from "zod";
+import type { sttnHeadListType } from "../coSttn/headList";
+import type {
+ CommonTableProps,
+ TableUpperProps,
+} from "../../common/type/header";
+import { ruseHstryHeadListExport } from "./headList";
+import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
+import type { DmdCoReqType } from "../coMatRvw/type";
+import toast from "react-hot-toast";
+import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
+
+const ruseHistHeadList = ruseHstryHeadListExport;
+
+export type ruseHstryState = {
+ ruseHist: {
+ isInit: boolean;
+ rvwHistRes: DmdCoReqType[];
+ ruseHistHeadList: TableUpperProps[];
+ };
+};
+
+export const ruseHstryStateExport: ruseHstryState = {
+ ruseHist: {
+ isInit: false,
+ rvwHistRes: [],
+ ruseHistHeadList: ruseHistHeadList,
+ },
+};
+
+export type ruseHstryType = ruseHstryState & ruseHstryActions;
+
+//
+export const addRgtrAndMdfrToDemandObj = (data: DmdCoReqType) => {
+ // 최상위 demand 객체
+ // demandCo가 있을 경우
+ if (data.demandCo) {
+ data.demandCo.rgtr = TEST_UUID;
+ data.demandCo.mdfr = TEST_UUID;
+ }
+
+
+ return data;
+};
+
+
+
+type ruseHstryActions = {
+ ruseRvwHistInit: (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd?: string
+ ) => void;
+ ruseRvwCalUpdate: (data: DmdCoReqType) => void;
+ ruseRvwSearch: (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string,
+ dmdCoNm: string,
+ ruseUtztnFcltNm: string
+ ) => void;
+ ruseRvwInqua: (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string
+ ) => void;
+ ruseRvwComplete:( data: Number[]) => void;
+};
+
+const irvwHistInit = async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+) => {
+ let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`;
+
+ // console.log("sggCd ", sggCd);
+ // if (sggCd) {
+ // url += `/${sggCd}`;
+ // }
+
+ const rvwHistRes = await getFetch(fetchType.WR, url);
+
+ return rvwHistRes;
+};
+
+export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
+ set: any
+) => {
+ return {
+ ruseRvwHistInit: async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd?: string
+ ) => {
+ const rvwHistRes = await irvwHistInit(
+ pageNo,
+ pageCnt,
+ startYear,
+ endYear,
+ // sggCd
+ );
+
+ return set((state: ruseHstryState) => ({
+ ...state,
+ ruseHist: {
+ ...state.ruseHist,
+ init: false,
+ rvwHistRes: rvwHistRes,
+ },
+ }));
+ },
+ ruseRvwCalUpdate: async (data: DmdCoReqType) => {
+ try {
+
+ const updatedData = addRgtrAndMdfrToDemandObj(data);
+ const update = await putFectch(
+ `/reuseFc/request/cst`,
+ updatedData
+ );
+ if (update.status === 200) {
+ toast.success("매칭 계산 저장이 완료입니다.");
+ const rvwHistRes = await irvwHistInit(
+ 1,
+ 10,
+ new Date().getFullYear().toString(),
+ new Date().getFullYear().toString(),
+ );
+ return set((state: ruseHstryState) => ({
+ ...state,
+ ruseHist: {
+ ...state.ruseHist,
+ init: false,
+ rvwHistRes: rvwHistRes,
+ },
+ }));
+ }
+ } catch (e) {
+ toast.error("매칭 계산 저장이 오류입니다.");
+ console.log(e);
+ }
+ },
+ ruseRvwSearch: async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string,
+ dmdCoNm: string,
+ ruseUtztnFcltNm: string
+ ) => {
+ let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`;
+
+ if (sggCd.length > 0) {
+ url += `/${sggCd}`;
+ } else {
+ url += `/0`;
+ }
+ if (dmdCoNm?.length > 0) {
+ url += `/${dmdCoNm}`;
+ } else {
+ url += `/0`;
+ }
+ if (ruseUtztnFcltNm?.length > 0) {
+ url += `/${ruseUtztnFcltNm}`;
+ } else {
+ url += `/0`;
+ }
+ const rvwHistRes = await getFetch(fetchType.WR, url);
+
+ return set((state: ruseHstryState) => ({
+ ...state,
+ ruseHist: {
+ ...state.ruseHist,
+ rvwHistRes: rvwHistRes,
+ },
+ }));
+ },
+ ruseRvwInqua: async (
+ pageNo: number,
+ pageCnt: number,
+ startYear: string,
+ endYear: string,
+ sggCd: string
+ ) => {
+ try {
+ let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`;
+ if (sggCd.length > 0) {
+ url += `/${sggCd}/0`;
+ }
+ const rvwHistRes = await getFetch(fetchType.WR, url);
+ return set((state: ruseHstryState) => ({
+ ...state,
+ ruseHist: {
+ ...state.ruseHist,
+ rvwHistRes: rvwHistRes,
+ },
+ }));
+ } catch (e) {
+ console.log(" error ", e);
+ }
+ },
+ ruseRvwComplete: async (data: Number[]) => {
+ try {
+ const complet = await postFectch(
+ `/reuseFc/request/completeCheck`,
+ data,
+ fetchType.WR
+ );
+ if (complet.status === 200) {
+ toast.success("완료 처리가 완료되었습니다.");
+ const rvwHistRes = await irvwHistInit(
+ 1,
+ 10,
+ new Date().getFullYear().toString(),
+ new Date().getFullYear().toString(),
+ );
+ }
+ } catch (e) {
+ console.log(" error ", e);
+ toast.error("완료 처리 중 오류가 발생했습니다.");
+ }
+ },
+ };
+};
+
+
+
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx
new file mode 100644
index 000000000..5754c02fc
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx
@@ -0,0 +1,137 @@
+import type { SelectDataType } from "@common/business_components";
+import type { rainChkZodType } from ".";
+import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import { buildingType } from "../../../common/code/index";
+export const useTypes = [
+ "조경용수",
+ "청소화장실용수",
+ "세척살수용수",
+ "농업용수",
+ "공업용수",
+ "친수용수",
+ "기타",
+];
+
+export type Buildingtype = {
+ bdstInfoPk: number;
+ ctpvCd: 1;
+ sggCd: 1001;
+ daddr: "string3";
+ bdstNm: "string";
+ frstArchPrmsnDt: "2025-03-25";
+ archArea: 0;
+ regDt: "2025-04-16";
+ rgtr: null;
+ mdfcnDt: "2025-04-16";
+ mdfr: null;
+};
+
+export const buildingToExcelType = (
+ buildings: Buildingtype[],
+ sidoCode: SelectDataType[],
+ sggCdoe: SelectDataType[],
+) => {
+ const excelData: string[][] = [];
+ buildings.forEach((building) => {
+ useTypes.forEach((useType) => {
+ excelData.push([
+ building.bdstInfoPk.toString(),
+ sidoCode.find((sido) => sido.val === building.ctpvCd.toString())
+ ?.text || "",
+ sggCdoe.find((sido) => sido.val === building.sggCd.toString())
+ ?.text || "",
+ building.daddr,
+ building.bdstNm,
+ "",
+ "",
+ "",
+ "",
+ useType,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ]);
+ });
+ });
+ return excelData;
+
+};
+
+export const excelToRainChkData = (excelData: any, year: string) => {
+ const rainChkgdData: rainChkZodType[] = excelData.map((item: any) => {
+ if (item["점검일"] !== undefined) {
+ const checkYmd = item["점검일"].replace(/\./g, "")
+ let vltnDt = item["과태료 부과일(위반일)"]
+ if (vltnDt !== undefined) {
+ vltnDt = vltnDt ? vltnDt.replace(/\./g, "") : "";
+ }
+ const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
+ let month = `${i + 1}`;
+ const splyData = item[`보급_${month}월`];
+ const ruseData = item[`빗물_${month}월`];
+ if (month.length < 2) month = "0" + month;
+ return {
+ utztnUsgCd: item["이용용도"],
+ ym: year + month,
+ chckYmd: checkYmd,
+ splyUswtrUtztnQnt: Number(splyData ?? 0),
+ ruseFcltUtztnQnt: Number(ruseData ?? 0),
+ flg: "RNB",
+ };
+ });
+
+ return {
+
+ bdstRuseFcltFk: Number(item["NO"]),
+ chckYmd: checkYmd,
+ spwtPositn: item["유량측정방법"] ?? "",
+ rgtr: TEST_UUID,
+ oilqMeasMthd: item["운영관리형태"] ?? "",
+ anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
+ operMngCd: item["유량측정방법"] ?? "",
+ guideDetails: makeGuidDetail,
+ rainyDetails: [
+ {
+ utztnUsgCd: item["이용용도"] ?? "",
+ ph: Number(item["PH"] ?? 0),
+ trbt: Number(item["탁도"] ?? 0),
+ grssClfg: Number(item["총대장균군수"] ?? 0),
+ etc: item["기타"] ?? "", // 필드 누락 방지
+ vltnDt: vltnDt ?? "",
+ vltnMttr: item["위반사항"] ?? "",
+ levyAmt: Number(item["과태료부과금액(천원)"] ?? 0),
+ rgtr: TEST_UUID,
+ },
+ ],
+ };
+ }
+ }).filter((el: any) => el !== undefined);
+ return rainChkgdData;
+};
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx
new file mode 100644
index 000000000..3cc75d70c
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx
@@ -0,0 +1,223 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import { z } from "zod";
+
+export const chkgdRegExcel = z.object({
+ bdstInfoPk: z.number().default(111111111),
+ chckYr: z
+ .string()
+ .default("")
+ .refine((year) => year.length === 0 || /^\d{4}$/.test(year), {
+ message: "4자리 연도만 입력하세요",
+ })
+ .refine(
+ (year) => {
+ if (year.length === 0) return true; // 빈 문자열은 통과
+ const numYear = Number(year);
+ return !isNaN(numYear) && numYear <= new Date().getFullYear();
+ },
+ { message: "현재 년도보다 높은 수를 입력할 수 없습니다." }
+ ),
+ file: z.instanceof(File).optional(),
+});
+
+export const guideDetail = z.object({
+ chkgdnFk: z.number().nullable(),
+ utztnUsgCd: z.string(),
+ chckYmd: z.string(),
+ ym: z.string(),
+ splyUswtrUtztnQnt: z.number(),
+ ruseFcltUtztnQnt: z.number(),
+ flg: z.string(),
+});
+export const rainChkZod = z.object({
+ chkgdnPk: z.number().nullable(),
+ bdstRuseFcltFk: z.number(),
+ chckYmd: z.string(),
+ cityText:z.string().nullish(),
+ sggText:z.string().nullish(),
+ prcsCpct: z.number().nullable(),
+ spwtPositn: z.string().nullable(),
+ regDt: z.string().nullable(),
+ rgtr: z.string().nullable(),
+ mdfcnDt: z.string().nullable(),
+ mdfr: z.string().nullable(),
+ flg: z.string().nullable(),
+ guideDetails: z.array(guideDetail),
+ building: z
+ .object({
+ bdstInfoPk: z.number(),
+ ctpvCd: z.number(),
+ sggCd: z.number(),
+ daddr: z.string().nullable(),
+ bdstNm: z.string(),
+ frstArchPrmsnDt: z.string().nullable(),
+ archArea: z.number(),
+ regDt: z.string().nullable(),
+ rgtr: z.string().nullable(),
+ mdfcnDt: z.string().nullable(),
+ mdfr: z.string().nullable(),
+ })
+ .nullable(),
+ rainyDetails: z.array(
+ z.object({
+ chkgdnFk: z.number().nullable(),
+ utztnUsgCd: z.string(),
+ ph: z.number().nullable(),
+ trbt: z.number().nullable(),
+ grssClfg: z.number().nullable(),
+ etc: z.string().nullable(),
+ vltnDt: z.string().nullable(),
+ vltnMttr: z.string().nullable(),
+ levyAmt: z.number().nullable(),
+ regDt: z.string().nullable(),
+ rgtr: z.string().nullable(),
+ mdfcnDt: z.string().nullable(),
+ mdfr: z.string().nullable(),
+ })
+ ),
+});
+
+export type chHeadType = {
+ headNm: string;
+ text: string;
+ length: number;
+ rows?: number;
+};
+
+export type splRuseWaterType = {
+ utztnUsgCd: string;
+ splTotal: number;
+ spl01: number;
+ spl02: number;
+ spl03: number;
+ spl04: number;
+ spl05: number;
+ spl06: number;
+ spl07: number;
+ spl08: number;
+ spl09: number;
+ spl10: number;
+ spl11: number;
+ spl12: number;
+ ruseTotal: number;
+ ruse01: number;
+ ruse02: number;
+ ruse03: number;
+ ruse04: number;
+ ruse05: number;
+ ruse06: number;
+ ruse07: number;
+ ruse08: number;
+ ruse09: number;
+ ruse10: number;
+ ruse11: number;
+ ruse12: number;
+};
+
+export const rainHeadNmExport: chHeadType[] = [
+ { headNm: "useQuilty", text: "이용수질(필요시)", length: 3 },
+ { headNm: "feeHist", text: "과태료 부과내역", length: 3 },
+ { headNm: "ruseWater", text: "연간보급수 이용량(m³)", length: 13 },
+ { headNm: "detailQulity", text: "분기", length: 11 },
+ { headNm: "splWater", text: "연간빗물 이용량(m³)", length: 13 },
+];
+
+export const rainChkgdnHeadListExport: TableUpperProps[] = [
+ { id: "order", title: "순번", mergeCell: true },
+ { id: "checkBox", title: "선택", mergeCell: true },
+ { id: "cityText", title: "시도", mergeCell: true },
+ { id: "sggText", title: "시군구", mergeCell: true },
+ { id: "bdstNm", title: "시설명", mergeCell: true },
+ { id: "operMngCd", title: "운영관리형태", mergeCell: true },
+ { id: "oilqMeasMthd", title: "유량측정방법", mergeCell: true },
+ { id: "anlOperCst", title: "연간운영비(원/년)", mergeCell: true },
+ { id: "dtfcltCpct", title: "빗물저류조용량(m³)", mergeCell: true },
+ { id: "chckYmd", title: "점검일", mergeCell: true },
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "totalSplyUswtrUtztnQnt", title: "연간보급수이용량(m³)" },
+ { id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" },
+ {
+ id: "ph",
+ title: "PH",
+ upName: "useQuilty",
+ upSequnce: 1,
+ type: "number",
+ edit: true,
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ upName: "useQuilty",
+ upSequnce: 2,
+ type: "number",
+ edit: true,
+ },
+ {
+ id: "grssClfg",
+ title: "총대장균군수",
+ upName: "useQuilty",
+ upSequnce: 3,
+ type: "number",
+ edit: true,
+ },
+
+ {
+ id: "vltnDt",
+ title: "부과일(위반일)",
+ upName: "feeHist",
+ upSequnce: 1,
+ type: "text",
+ edit: true,
+ },
+ {
+ id: "vltnMttr",
+ title: "위반사항",
+ upName: "feeHist",
+ upSequnce: 2,
+ type: "text",
+ edit: true,
+ },
+ {
+ id: "levyAmt",
+ title: "부과금액(천원)",
+ upName: "feeHist",
+ upSequnce: 3,
+ type: "number",
+ edit: true,
+ },
+];
+
+export const ruseHeadListExport: TableUpperProps[] = [
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 },
+ { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 , edit: true },
+ { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 , edit: true },
+ { id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 , edit: true },
+ { id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 , edit: true },
+ { id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 , edit: true },
+ { id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 , edit: true },
+ { id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 , edit: true },
+ { id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 , edit: true },
+ { id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10, edit: true },
+ { id: "ruse10", title: "10월", upName: "ruseWater", upSequnce: 11 , edit: true },
+ { id: "ruse11", title: "11월", upName: "ruseWater", upSequnce: 12 , edit: true },
+ { id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 , edit: true },
+];
+
+export const splHeadListExport: TableUpperProps[] = [
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1},
+ { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2, edit: true },
+ { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3, edit: true },
+ { id: "spl03", title: "3월", upName: "splWater", upSequnce: 4, edit: true },
+ { id: "spl04", title: "4월", upName: "splWater", upSequnce: 5, edit: true },
+ { id: "spl05", title: "5월", upName: "splWater", upSequnce: 6, edit: true },
+ { id: "spl06", title: "6월", upName: "splWater", upSequnce: 7, edit: true },
+ { id: "spl07", title: "7월", upName: "splWater", upSequnce: 8, edit: true },
+ { id: "spl08", title: "8월", upName: "splWater", upSequnce: 9, edit: true },
+ { id: "spl09", title: "9월", upName: "splWater", upSequnce: 10, edit: true },
+ { id: "spl10", title: "10월", upName: "splWater", upSequnce: 11, edit: true },
+ { id: "spl11", title: "11월", upName: "splWater", upSequnce: 12, edit: true },
+ { id: "spl12", title: "12월", upName: "splWater", upSequnce: 13, edit: true },
+];
+
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx
new file mode 100644
index 000000000..ff612a0fb
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx
@@ -0,0 +1,271 @@
+import { buildingType } from "@/app/store/common/code";
+import {
+ TEST_UUID,
+} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import {
+ deleteFectch,
+ fetchType,
+ getFetch,
+ postFectch,
+ putFectch,
+} from "@/components/lib/api";
+import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
+import type { SelectDataType } from "@common/business_components/ui";
+import { z } from "zod";
+import { buildingToExcelType } from "./excel";
+import {
+ rainChkgdnHeadListExport,
+ rainChkZod,
+ rainHeadNmExport,
+ ruseHeadListExport,
+ splHeadListExport,
+ type chHeadType,
+} from "./headList";
+import type { TableUpperProps } from "@/app/store/common/type/header";
+
+export type rainChkZodType = z.infer;
+const fcltDiv = [
+ { val: "RST", text: "중수도시설" },
+ { val: "RNB", text: "빗물이용시설" },
+];
+
+const rainHeadNm = rainHeadNmExport;
+const rainChkgdnHeadList = rainChkgdnHeadListExport;
+const ruseHeadList = ruseHeadListExport;
+const splHeadList = splHeadListExport;
+
+const rainChk: rainChkZodType[] = [];
+
+export type rainChkgdnState = {
+ rainChkgdn: {
+ rainChkgdnHeadList: TableUpperProps[];
+ rainChk: rainChkZodType[];
+ rainHeadNm: chHeadType[];
+ ruseHeadList: TableUpperProps[];
+ splHeadList: TableUpperProps[];
+ isInit: boolean;
+ isModalClose: boolean;
+ fcltDiv: SelectDataType[];
+ excelList: [];
+ isSttn: boolean;
+ };
+};
+
+type rainChkgdnActions = {
+ rainChkInit: (sggCd: string, searchTxt: string) => void;
+ rainChkDetilUpdate(rainChk: rainChkZodType[]): Promise;
+ rainChkGuidUpdate(rainChk: rainChkZodType): Promise;
+ rainChkExcelDownload(
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+ ): Promise;
+ rainChkExcelDataUPload(excelData: rainChkZodType[]): Promise;
+ rainChkDelete(chkgdnPks: number[]): Promise;
+ rainChkHeadChange: (rainChkgdn: rainChkgdnState, isEdit :boolean) => void;
+};
+
+export type rainChkgdnType = rainChkgdnState & rainChkgdnActions;
+
+export const rainChkgdnStateExport: rainChkgdnState = {
+ rainChkgdn: {
+ rainChkgdnHeadList: rainChkgdnHeadList,
+ rainHeadNm: rainHeadNm,
+ rainChk: rainChk,
+ splHeadList: splHeadList,
+ ruseHeadList: ruseHeadList,
+ isInit: false,
+ isModalClose: false,
+ excelList: [],
+ fcltDiv: fcltDiv,
+ isSttn: false,
+ },
+};
+
+const makeMdfrChk = (data: rainChkZodType[], type: string, toDo: string) => {
+ const chData = data.map((item) => {
+ item.mdfr = TEST_UUID;
+ item.rgtr = TEST_UUID;
+ if (type === "rainyDetails") {
+ item.rainyDetails.forEach((item) => {
+ item.mdfr = TEST_UUID;
+ item.rgtr = TEST_UUID;
+ });
+ } else {
+ }
+ return item;
+ });
+
+ return chData;
+};
+
+const initFetch = async (txt: string | undefined, sgg: string | undefined) => {
+ const rainRes = await getFetch(
+ "wr",
+ `/reuseChk/rainy` + (txt ? `/${txt}` : "2024") + (sgg ? `/${sgg}` : "/0")
+ );
+ return rainRes;
+};
+
+export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
+ set: any
+) => {
+ return {
+ rainChkExcelDownload: async (
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+ ) => {
+ // 로그인한 아이디의 시도 or 시군구로 들어가야하는데 현재는 그냥 0으로 하드코딩
+ const data = await getFetch(
+ fetchType.WR,
+ `/reuseFc/buildingFlg/${buildingType.RNB}/41`
+ );
+ const excelList = buildingToExcelType(data, sidoCode, sggCode);
+ set((state: rainChkgdnState) => ({
+ rainChkgdn: {
+ ...state.rainChkgdn,
+ excelList: excelList,
+ },
+ }));
+ },
+ rainChkExcelDataUPload: async (excelData: rainChkZodType[]) => {
+ try {
+ const res = await postFectch("/reuseChk/rainy", excelData);
+ if (res.ok) {
+ ToastFormUi({
+ body: "지도점검 등록이 완료되었습니다. ",
+ title: "지도점검 등록",
+ });
+ }
+ const rainChkRes = await initFetch("2024", "0");
+ return set((state: rainChkgdnState) => ({
+ ...state,
+ rainChkgdn: {
+ ...state.rainChkgdn,
+ rainChk: rainChkRes,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ ToastFormUi({
+ body: "지도점검 등록이 실패되었습니다.",
+ title: "지도점검 등록",
+ });
+ }
+ },
+ rainChkInit: async (searchTxt: string, sggCd: string) => {
+ try {
+ const rainChkRes = await initFetch(searchTxt, sggCd);
+
+ return set((state: rainChkgdnState) => ({
+ ...state,
+ rainChkgdn: {
+ ...state.rainChkgdn,
+ rainChk: rainChkRes,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ rainChkDetilUpdate: async (rainChk: rainChkZodType[]) => {
+ try {
+ const chData = await makeMdfrChk(rainChk, "rain", "rainDetil");
+
+ const res = await postFectch("/reuseChk/rainy", chData);
+ if (res.ok) {
+ ToastFormUi({
+ body: "지도점검 보급수 및 밋물이용량 수정이 완료되었습니다. ",
+ title: "지도점검 수정",
+ });
+ }
+ const rainChkRes = await initFetch("2024", "0");
+ return set((state: rainChkgdnState) => ({
+ ...state,
+ rainChkgdn: {
+ ...state.rainChkgdn,
+ rainChk: rainChkRes,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ alert("수정에 실패하였습니다.");
+ }
+ },
+ rainChkGuidUpdate: async (rainChk: rainChkZodType) => {
+ try {
+ //const chData = await makeMdfrChk(rainChk, "guideDetails", "rainDetil");
+ const res = await putFectch("/reuseChk/rainy", rainChk);
+ if (res.ok) {
+ ToastFormUi({
+ body: "지도점검 수질 및 과태료 수정이 완료되었습니다. ",
+ title: "지도점검 수정",
+ });
+ }
+ const rainChkRes = await initFetch("2024", "0");
+ return set((state: rainChkgdnState) => ({
+ ...state,
+ rainChkgdn: {
+ ...state.rainChkgdn,
+ rainChk: rainChkRes,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ rainChkDelete: async (chkgdnPks: number[]) => {
+ try {
+ const res = await deleteFectch(`/reuseChk/rainy`, chkgdnPks);
+
+ if (res) {
+ ToastFormUi({
+ body: "삭제가 완료되었습니다. ",
+ title: "지도점검 삭제",
+ });
+ }
+ const rainChkRes = await initFetch("2024", "0");
+ return set((state: rainChkgdnState) => ({
+ ...state,
+ rainChkgdn: {
+ ...state.rainChkgdn,
+ rainChk: rainChkRes,
+ },
+ }));
+ } catch (error) {
+ ToastFormUi({ body: "삭제를 실패했습니다.. ", title: "지도점검 삭제" });
+ }
+ },
+ rainChkHeadChange: async (rainChkgdn: rainChkgdnState , isEdit :boolean) => {
+ try {
+ const rainChkgdnHeadList = rainChkgdn.rainChkgdn.rainChkgdnHeadList;
+ const splHeadList = rainChkgdn.rainChkgdn.splHeadList;
+ const ruseHeadList = rainChkgdn.rainChkgdn.ruseHeadList;
+
+ rainChkgdnHeadList.forEach(( head) => {
+ if(head.edit!== undefined)
+ head.edit=isEdit;
+ });
+ splHeadList.forEach((head) => {
+ if(head.edit!== undefined)
+ head.edit=isEdit;
+ });
+ ruseHeadList.forEach((head) => {
+ if(head.edit!== undefined)
+ head.edit=isEdit;
+ });
+
+ return set((state: rainChkgdnState) => ({
+ ...state,
+ rainChkgdn: {
+ ...state.rainChkgdn,
+ rainChkgdnHeadList: rainChkgdnHeadList,
+ splHeadList:splHeadList,
+ ruseHeadList:ruseHeadList
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ };
+};
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx
new file mode 100644
index 000000000..1364d6660
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx
@@ -0,0 +1,237 @@
+import type { SelectDataType } from "@common/business_components/ui";
+import { useTypes, type Buildingtype } from "../rainChkgdn/excel";
+import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import type { rswtChkZodType } from ".";
+
+export const rswtMakeExcelSample = (
+ buildings: Buildingtype[],
+ sidoCode: SelectDataType[],
+ sggCdoe: SelectDataType[]
+) => {
+ const excelSite = {
+ guideDetail: [] as string[][],
+ polutions: [] as string[][],
+ };
+ //첫번째 시트 데이터 이용량 현황 양식만들기
+ buildings.forEach((building) => {
+ useTypes.forEach((useType) => {
+ excelSite.guideDetail.push([
+ building.bdstInfoPk.toString(),
+ sidoCode.find((sido) => sido.val === building.ctpvCd.toString())
+ ?.text || "",
+ sggCdoe.find((sido) => sido.val === building.sggCd.toString())?.text ||
+ "",
+ building.bdstNm,
+ building.daddr,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ useType,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ]);
+ });
+ });
+
+ //두번째 시트 양식 만들기 오염도
+ buildings.forEach((building) => {
+ useTypes.forEach((useType) => {
+ excelSite.polutions.push([
+ building.bdstInfoPk.toString(),
+ sidoCode.find((sido) => sido.val === building.ctpvCd.toString())
+ ?.text || "",
+ sggCdoe.find((sido) => sido.val === building.sggCd.toString())?.text ||
+ "",
+ building.bdstNm,
+ building.daddr,
+ "",
+ "",
+ "",
+ "",
+ "",
+ useType,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ]);
+ });
+ });
+
+ return excelSite;
+};
+
+export const excelToRswtGuideData = (excelData: any, year: string) => {
+ const rainChkgdData: rswtChkZodType[] = excelData
+ .map((item: any) => {
+ if (item["점검일"] !== undefined) {
+
+ const checkYmd = item["점검일"].replace(/\./g, "")
+
+ const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
+ let month = `${i + 1}`;
+ const splyData = item[`대체수_${month}월`];
+ const rswtData = item[`중수_${month}월`];
+ if (month.length < 2) month = "0" + month;
+ return {
+ ym: year + month,
+ chckYmd: checkYmd,
+ splyUswtrUtztnQnt: splyData !== "" ? splyData : 0,
+ ruseFcltUtztnQnt: rswtData !== "" ? rswtData : 0,
+ };
+ });
+
+ return {
+ bdstRuseFcltFk: Number(item["NO"]),
+ operMngCd: item["운영관리형태"],
+ anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
+ prcsCpct: item["처리용량(m³)"],
+ spwtPositn: item["채수지점"],
+ chckYmd:checkYmd,
+ utztnUsgCd: item["이용용도"],
+ guideDetails: makeGuidDetail,
+ rgtr: TEST_UUID,
+ mdfr: TEST_UUID,
+
+ };
+ }
+ })
+ .filter((el: any) => el !== undefined);
+ return rainChkgdData;
+};
+
+export const excelToRswtPolution = (excelData: any, year: string) => {
+ const rainChkgdData: rswtChkZodType[] = excelData
+ .map((item: any) => {
+ if (item["점검일"] !== undefined) {
+
+ const checkYmd = item["점검일"].replace(/\./g, "")
+ let vltnDt = item["과태료 부과일(위반일)"]
+ if (vltnDt !== undefined) {
+ vltnDt = vltnDt .replace(/\./g, "")
+ }
+
+
+ const makePoluttion = Array.from({ length: 4 }, (_, i) => {
+ let quarter = `${i+1}`;
+ const grssClfgUswtr = item[`${quarter}분기_총대장균군수`];
+ const combResdch = item[`${quarter}분기_결합잔류염소`];
+ const trbt = item[`${quarter}분기_탁도`];
+ const bod = item[`${quarter}분기_BOD`];
+ const smll = item[`${quarter}분기_냄새`];
+ const crmty = item[`${quarter}분기_색도`];
+ const tph = item[`${quarter}분기_T-P`];
+ const tn = item[`${quarter}분기_T-N`];
+ const ph = item[`${quarter}분기_PH`];
+ const clIonQnt = item[`${quarter}분기_염화물`];
+
+ return {
+
+ node: quarter,
+ chckYmd: checkYmd,
+ grssClfgUswtr: grssClfgUswtr !== "" ? grssClfgUswtr : 0,
+ combResdch: combResdch !== "" ? combResdch : 0,
+ trbt: trbt !== "" ? trbt : 0,
+ bod: bod !== "" ? bod : 0,
+ smll: smll !== "" ? smll : 0,
+ crmty: crmty !== "" ? crmty : 0,
+ tph: tph !== "" ? tph : 0,
+ tn: tn !== "" ? tn : 0,
+ ph: ph !== "" ? ph : 0,
+ clIonQnt: clIonQnt !== "" ? clIonQnt : 0,
+ rgtr: TEST_UUID,
+ mdfr: TEST_UUID,
+ };
+ });
+
+ return {
+ bdstRuseFcltFk: Number(item["NO"]),
+ chckYmd: checkYmd,
+ utztnUsgCd: item["이용용도"],
+ operMngCd: item["운영관리형태"],
+ anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
+ prcsCpct: item["처리용량(m³)"],
+ spwtPositn: item["채수지점"],
+ rswtrPollutions: makePoluttion,
+ rgtr: TEST_UUID,
+ mdfr: TEST_UUID,
+ rswtrDetails: [
+ {
+ utztnUsgCd: item["이용용도"],
+ vltnDt:vltnDt,
+ vltnMttr: item["위반사항"],
+ levyAmt: Number(item["과태료 부과금액(천원)"]) ?? 0,
+ rgtr: TEST_UUID,
+ mdfr: TEST_UUID,
+ },
+ ],
+ };
+ }
+ })
+ .filter((el: any) => el !== undefined);
+ return rainChkgdData;
+};
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx
new file mode 100644
index 000000000..0e690dbb9
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx
@@ -0,0 +1,231 @@
+import { z } from "zod";
+import { guideDetail, type chHeadType } from "../rainChkgdn/headList";
+import type { TableUpperProps } from "@/app/store/common/type/header";
+
+export type polutionType = {
+ chkgdnDtlFk: number;
+ utztnUsgCd: string;
+ node: number;
+ grssClfgUswtr: number;
+ combResdch: number;
+ trbt: number;
+ bod: number;
+ smll: number;
+ crmty: number;
+ tph: number;
+ tn: number;
+ ph: number;
+ clIonQnt: number;
+ edit?:boolean
+};
+const reuseBuildingZod = z.object({
+ bdstRuseFcltPk: z.number().nullish(),
+ bdstInfoFk: z.number().nullish(),
+ instlCmptnDt: z.string().nullable(), // Assuming it's a date string or null
+ instlCst: z.number(),
+ operMngCd: z.string().nullable(),
+ instlCstSprtYn: z.string().nullable(), // Assuming 'Y'/'N' or similar, or null
+ instlCstSprtAmt: z.number(),
+ grntchBdstCertYn: z.string().nullable(),
+ grntchBdstCertYr: z.string().nullable(), // Could be z.number().nullable() if it's strictly a year number
+ grntchBdstCertNo: z.string().nullable(),
+ grntchBdstCertGrd: z.string().nullable(),
+ crgRdctYn: z.string().nullable(),
+ crgRdctBss: z.string().nullable(),
+ crgRdctAmt: z.number(),
+ ruseFcltFlg: z.string().nullable(),
+ bdstUsgCd: z.number(),
+ lawTrgtYn: z.string().nullable(), // Assuming 'Y'/'N' or similar, or null
+ rgtr: z.string(), // Assuming this is a UUID
+ mdfr: z.string(), // Assuming this is a UUID
+});
+
+const buildingZod = z.object({
+ bdstInfoPk: z.number().nullable(),
+ ctpvCd: z.number(),
+ sggCd: z.number(),
+ daddr: z.string().nullable(),
+ bdstNm: z.string(),
+ frstArchPrmsnDt: z.string().nullable(), // Assuming it's a date string or null
+ archArea: z.number(),
+ rgtr: z.string(), // Assuming this is a UUID
+ mdfr: z.string(), // Assuming this is a UUID
+});
+
+export const rswtrPolutionsZode = z.object({
+ chkgdnDtlFk: z.string().nullish(),
+ utztnUsgCd: z.string().nullish(),
+ node: z.string().nullish(),
+ grssClfgUswtr: z.number(),
+ combResdch: z.number(),
+ trbt: z.number(),
+ bod: z.number(),
+ smll: z.number(),
+ crmty: z.number(),
+ tph: z.number(),
+ tn: z.number(),
+ ph: z.number(),
+ clIonQnt: z.number(),
+ regDt: z.string().nullish(),
+ rgtr: z.string().nullish(),
+ mdfcnDt: z.string().nullish(),
+ mdfr: z.string().nullish(),
+ edit:z.boolean().nullish()
+});
+
+export const rswtrDetailsZod = z.object({
+ chkgdnDtlPk: z.string().nullish(),
+ chkgdnFk: z.string().nullish(),
+ utztnUsgCd: z.string(),
+ vltnDt: z.string(),
+ vltnMttr: z.string(),
+ levyAmt: z.number(),
+ regDt: z.string().nullish(),
+ rgtr: z.string().nullish(),
+ mdfcnDt: z.string().nullish(),
+ mdfr: z.string().nullish(),
+})
+
+export const rswtChkgdZod = z.object({
+ chkgdnPk: z.number().nullish(),
+ bdstRuseFcltFk: z.number().nullish(),
+ chckYmd: z.string(),
+ prcsCpct: z.number(),
+ dtfcltCpct: z.number(),
+ spwtPositn: z.string(),
+ regDt: z.string().nullish(),
+ rgtr: z.string().nullish(),
+ mdfcnDt: z.string().nullish(),
+ mdfr: z.string().nullish(),
+ anlOperCst:z.number(),
+ oilqMeasMthd: z.string().nullish(),
+ utztnUsgCd: z.string(),
+ building: buildingZod,
+ guideDetails: z.array(guideDetail),
+ reuseBuilding: reuseBuildingZod,
+ rswtrDetails: z.array(
+ rswtrDetailsZod
+ ),
+ rswtrPollutions: z.array(rswtrPolutionsZode),
+});
+
+export const rswtHeadNmExport: chHeadType[] = [
+ { headNm: "useQuilty", text: "연간 평균 이용수질", length: 10 },
+ { headNm: "feeHist", text: "과태료 부과내역", length: 3 },
+];
+
+export const rswtChkHeadListExport: TableUpperProps[] = [
+ { id: "order", title: "순번", mergeCell: true },
+ { id: "checkBox", title: "선택", mergeCell: true },
+ { id: "cityText", title: "시도" ,mergeCell: true },
+ { id: "sggText", title: "시군구",mergeCell: true },
+ { id: "bdstNm", title: "시설명" ,mergeCell: true},
+ { id: "operMngCd", title: "운영관리형태" ,mergeCell: true},
+ { id: "anlOperCst", title: "연간운영비(원/년)" ,mergeCell: true},
+ { id: "prcsCpct", title: "처리용량(m³)" ,mergeCell: true},
+ { id: "spwtPositn", title: "채수지점" ,mergeCell: true},
+ { id: "chckYmd", title: "점검일" ,mergeCell: true},
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "splyUswtrUtztnQnt", title: "연간보급수이용량(m³)" ,type: "number"},
+ { id: "ruseFcltUtztnQnt", title: "연간중수도이용량(m³)",type: "number"},
+
+ {
+ id: "grssClfgUswtr",
+ title: "총대장균군수",
+ upName: "useQuilty",
+ upSequnce: 1,
+ type: "number"
+ },
+ {
+ id: "combResdch",
+ title: "결합잔류염소",
+ upName: "useQuilty",
+ upSequnce: 2,
+ type: "number"
+ },
+ { id: "trbt", title: "탁도", upName: "useQuilty", upSequnce: 3 ,type: "number"},
+ { id: "bod", title: "BOD", upName: "useQuilty", upSequnce: 4 ,type: "number"},
+ { id: "smll", title: "냄새", upName: "useQuilty", upSequnce: 5 ,type: "number"},
+ { id: "crmty", title: "색도", upName: "useQuilty", upSequnce: 6 ,type: "number"},
+ { id: "tn", title: "T-N", upName: "useQuilty", upSequnce: 7 ,type: "number"},
+ { id: "tph", title: "T-P", upName: "useQuilty", upSequnce: 8 ,type: "number"},
+ { id: "ph", title: "PH", upName: "useQuilty", upSequnce: 9,type: "number" },
+ { id: "clIonQnt", title: "염화물", upName: "useQuilty", upSequnce: 10 ,type: "number"},
+
+ {
+ id: "vltnDt",
+ title: "부과일(위반일)",
+ upName: "feeHist",
+ upSequnce: 1,
+ type: "text",
+ edit:true
+ },
+ {
+ id: "vltnMttr",
+ title: "위반사항",
+ upName: "feeHist",
+ upSequnce: 2,
+ type: "text",
+ edit:true
+ },
+ {
+ id: "levyAmt",
+ title: "부과금액(천원)",
+ upName: "feeHist",
+ upSequnce: 3,
+ type: "number",
+ edit:true
+ }];
+
+
+ export const rswtDetailHeadListExport: TableUpperProps[] = [
+ { id: "utztnUsgCd", title: "이용용도" },
+
+ {
+ id: "grssClfgUswtr",
+ title: "총대장균군수",
+ upName: "detailQulity",
+ upSequnce: 2,
+ edit: true,
+ },
+ {
+ id: "combResdch",
+ title: "결합잔류염소",
+ upName: "detailQulity",
+ upSequnce: 3,
+ edit: true,
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ upName: "detailQulity",
+ upSequnce: 4,
+ edit: true,
+ },
+ { id: "bod", title: "BOD", upName: "detailQulity", upSequnce: 5, edit: true },
+ {
+ id: "smll",
+ title: "냄새",
+ upName: "detailQulity",
+ upSequnce: 6,
+ edit: true,
+ },
+ {
+ id: "crmty",
+ title: "색도",
+ upName: "detailQulity",
+ upSequnce: 7,
+ edit: true,
+ },
+ { id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8, edit: true },
+ { id: "tph", title: "T-P", upName: "detailQulity", upSequnce: 9, edit: true },
+ { id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10, edit: true },
+ {
+ id: "clIonQnt",
+ title: "염화물",
+ upName: "detailQulity",
+ upSequnce: 11,
+ edit: true,
+ },
+ ];
+
\ No newline at end of file
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx
new file mode 100644
index 000000000..eb0010047
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx
@@ -0,0 +1,299 @@
+import {
+ TEST_UUID,
+} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import type {
+ SelectDataType,
+ SheetParameter,
+} from "@common/business_components";
+import {
+ deleteFectch,
+ fetchType,
+ getFetch,
+ postFectch,
+ putFectch,
+} from "@/components/lib/api";
+import { buildingType } from "@/app/store/common/code";
+import { rswtMakeExcelSample } from "./excel";
+import {
+ rswtChkgdZod,
+ rswtChkHeadListExport,
+ rswtDetailHeadListExport,
+ rswtHeadNmExport,
+ rswtrDetailsZod,
+} from "./headList";
+import { z } from "zod";
+import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
+import { type chHeadType } from "../rainChkgdn/headList";
+import type { TableUpperProps } from "@/app/store/common/type/header";
+
+const rswtChkHeadList = rswtChkHeadListExport;
+const rswtDetailHeadList = rswtDetailHeadListExport;
+const rswtHeadNm = rswtHeadNmExport;
+export type rswtChkZodType = z.infer;
+export type rswtrChkDetailsZodType = z.infer;
+export type rswtChkgdnState = {
+ rswtChkgdn: {
+ rswtChkHeadList: TableUpperProps[];
+ rswtDetailHeadList: TableUpperProps[];
+
+ rswtHeadNm: chHeadType[];
+ excelList: SheetParameter[];
+ rswtChkRes: rswtChkZodType[];
+ rswtChkPolGuide: rswtChkZodType[];
+ isInit: boolean;
+ isSttn:boolean
+ };
+};
+
+type rswtChkgdnActions = {
+ rswtChkgdnInit: (year: string, sggCd: string) => void;
+ rswtrChkExcelDownload(
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+ ): Promise;
+ rswtChkExceDataUpload: (excelData: rswtChkZodType[]) => void;
+ rswtChkDelete: (chkgdnPks: number[]) => void;
+ rswtChkDetilsUpdate: (rswtChkDetails: rswtrChkDetailsZodType[]) => void;
+ rswtChkPolAndGuide: (chkGdnPk: number) => void;
+ rswtChkPolInit: () => void;
+ rwstPolAndGuideUpdate: (rswtChk: rswtChkZodType[]) => void;
+ rswtChkHeadChange: (rswtChkgdn: rswtChkgdnState, isEdit: boolean) => void;
+};
+
+export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions;
+
+export const rswtChkgdnStateExport: rswtChkgdnState = {
+ rswtChkgdn: {
+ rswtChkHeadList: rswtChkHeadList,
+ rswtDetailHeadList: rswtDetailHeadList,
+ rswtHeadNm: rswtHeadNm,
+ excelList: [{
+ data: [[]], headerNum: 0, headerRange: "A1:V3",
+ sheetName: "",
+ startCol: '1'
+ }],
+ rswtChkRes: [],
+ rswtChkPolGuide: [],
+ isInit: false,
+ isSttn:false,
+ },
+};
+
+const initFetch = async (year: string | undefined, sgg: string | undefined) => {
+ const rswtChkRes = await getFetch(
+ "wr",
+ `/reuseChk/reuseWater/` +
+ (year ? `${year}` : "2024") +
+ (sgg ? `/${sgg}` : "/0")
+ );
+ return rswtChkRes;
+};
+
+const makeMdfrChk = (data: rswtChkZodType[] | rswtrChkDetailsZodType[]) => {
+ const chData = data.map((item) => {
+ item.mdfr = TEST_UUID;
+ item.rgtr = TEST_UUID;
+ if ("rswtrPollutions" in item) {
+ item?.rswtrPollutions.forEach((pollution) => {
+ pollution.mdfr = TEST_UUID;
+ pollution.rgtr = TEST_UUID;
+ });
+ }
+ return item;
+ });
+ return chData;
+};
+
+export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
+ set: any
+) => {
+ return {
+ rswtrChkExcelDownload: async (
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+ ) => {
+ const data = await getFetch(
+ fetchType.WR,
+ `/reuseFc/buildingFlg/${buildingType.RST}/41`
+ );
+ const excelList: any = [];
+ const exceldata = rswtMakeExcelSample(data, sidoCode, sggCode);
+ excelList.push({
+ data: exceldata.guideDetail,
+ headerNum: 0,
+ headerRange: "A1:AI1",
+ });
+ excelList.push({
+ data: exceldata.polutions,
+ headerNum: 0,
+ headerRange: "A1:AZ1",
+ });
+
+ return set((state: rswtChkgdnState) => ({
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ excelList: excelList,
+ },
+ }));
+ },
+ rswtChkgdnInit: async (year: string, sggCd: string) => {
+ try {
+ const rswtChkRes = await initFetch("2024", sggCd);
+
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkRes: rswtChkRes,
+ isInit: false,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ rswtChkExceDataUpload: async (excelData: rswtChkZodType[]) => {
+ try {
+ const res = await postFectch("/reuseChk/reuseWater", excelData);
+ if (res.ok) {
+ ToastFormUi({
+ body: "지도점검 등록이 완료되었습니다.",
+ title: "지도점검 등록",
+ });
+ }
+ // const rainChkRes = await initFetch('2024', '0');
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ rswtChkDetilsUpdate: async (rswtChk: rswtrChkDetailsZodType[]) => {
+ try {
+ const chData = await makeMdfrChk(rswtChk);
+
+
+ const res = await putFectch("/reuseChk/reuseWater", chData);
+ if (res.ok) {
+ ToastFormUi({
+ body: "지도점검 과태료 수정 수정이 완료되었습니다. ",
+ title: "지도점검 수정",
+ });
+ }
+ const rswtChkRes = await initFetch("2024", "0");
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkRes: rswtChkRes,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ alert("수정에 실패하였습니다.");
+ }
+ },
+ rswtChkDelete: async (chkgdnPks: number[]) => {
+ try {
+ const res = await deleteFectch(`/reuseChk/reuseWater`, chkgdnPks);
+
+ if (res.ok) {
+ ToastFormUi({
+ body: "삭제가 완료되었습니다. ",
+ title: "지도점검 삭제",
+ });
+ }
+ const rswtChkRes = await initFetch("2024", "0");
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkRes: rswtChkRes,
+ },
+ }));
+ } catch (error) {
+ ToastFormUi({ body: "삭제를 실패했습니다.. ", title: "지도점검 삭제" });
+ }
+ },
+ rswtChkPolAndGuide: async (chkGdnPk: number) => {
+ try {
+ const rswtChkPolGuide = await getFetch(
+ "wr",
+ `/reuseChk/reuseWater/${chkGdnPk}`
+ );
+
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkPolGuide: rswtChkPolGuide,
+ },
+ }));
+ } catch (error) {}
+ },
+ rswtChkPolInit: () => {
+ try {
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkPolGuide: undefined,
+ },
+ }));
+ } catch (error) {}
+ },
+ rwstPolAndGuideUpdate: async (rswtChk: rswtChkZodType[]) => {
+ try {
+ const chData = await makeMdfrChk(rswtChk);
+ const res = await putFectch(
+ `/reuseChk/reuseWater/${rswtChk[0]?.chkgdnPk}`,
+ chData[0]
+ );
+ if (res.ok) {
+ ToastFormUi({
+ body: "지도점검 연간 수질 및 보급수/중수도 수정이 완료되었습니다. ",
+ title: "지도점검 수정",
+ });
+ }
+ const rswtChkRes = await initFetch("2024", "0");
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkRes: rswtChkRes,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ ToastFormUi({
+ body: "지도점검 연간 수질 및 보급수/중수도 수정이 실패하였습니다.. ",
+ title: "지도점검 수정",
+ });
+ }
+ },
+ rswtChkHeadChange: async (rswtChkgdn: rswtChkgdnState, isEdit: boolean) => {
+ try {
+ const rswtChkHeadList = rswtChkgdn.rswtChkgdn.rswtChkHeadList;
+ const rswtDetailHeadList = rswtChkgdn.rswtChkgdn.rswtDetailHeadList;
+ rswtChkHeadList.forEach((head) => {
+ if (head.edit !== undefined) head.edit = isEdit;
+ });
+ rswtDetailHeadList.forEach((head) => {
+ if (head.edit !== undefined) head.edit = isEdit;
+ });
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkHeadList: rswtChkHeadList,
+ rswtDetailHeadList: rswtDetailHeadList,
+ },
+ }));
+ } catch (e) {}
+ },
+ };
+};
diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx
new file mode 100644
index 000000000..d8160cab9
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx
@@ -0,0 +1,55 @@
+import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
+
+type NameMap = {
+ [key: string]: string;
+};
+
+ const nameMap:NameMap = {
+ "세척수": "wshwtr",
+ "냉각수": "coolUswtr",
+ "청소수": "cleanUswtr",
+ "식수대": "drwtUswtr",
+ "희석용수": "dltnUswtr",
+ "중수도": "ithlRswtr",
+ "기타": "ithlEtcUswtr",
+ "청소화장실용수": "cleanToilUswtr",
+ "세척살수용수": "resn",
+ "조경용수": "lndwtr",
+ "친수용수": "hydUswtr",
+ "지하수충전": "ugwtChr",
+ "농업용수": "farmUswtr",
+ "하천등유지용수": "rvrKeepUswtr",
+ "공업용수": "indstUswtr"
+ };
+
+
+export const excelToPbnPrfData = (excelData: JSON[], year: string,pbnstRuseFcltFk:string) => {
+ // 월별 데이터 하나로 병합
+ const merged = {} as any;
+ excelData.forEach((item: any) => {
+ const usageNm = item["용수명"]
+ const key = nameMap[usageNm as any];
+ if (!key) return;
+
+ for (let i = 1; i <= 12; i++) {
+ const month = i.toString().padStart(2, "0");
+ const ym = year + month;
+
+
+ if (!merged[ym]) merged[ym] = { ym };
+ merged[ym][key] = Number(item[`${i}월`] ?? 0);
+ }
+ });
+
+ const pbnPrfData = Object.values(merged);
+ const data = pbnPrfData.map((item) => {
+
+ return({
+ ...(item as object),
+ pbnstRuseFcltFk:pbnstRuseFcltFk,
+ rgtr: TEST_UUID,
+ mdfr: TEST_UUID,
+ })
+ })
+ return data;
+};
\ No newline at end of file
diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx
new file mode 100644
index 000000000..544f07516
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx
@@ -0,0 +1,38 @@
+import { z } from "zod";
+import type { TableUpperProps } from "../../common/type/header";
+
+export const pbnPrfRegExcelZod = z.object({
+ ym: z.string().default(""),
+ bscFctNm: z.string().default(""),
+ pbnstRuseFcltFk:z.string(),
+ pbnstRuseFcltNm: z.string().default(""),
+ file: z.instanceof(File).optional(),
+});
+
+export const pbnstPrfmncHeadListExport: TableUpperProps[] = [
+ { id: "sido", title: "시도" },
+ { id: "gugun", title: "시군구" },
+ { id: "bscFctNm", title: "시설명" },
+ { id: "ruseUtztnFcltNm", title: "재이용시설명" },
+ { id: "pbnstRuseFcltPk", title: "재이용시설코드" },
+];
+
+export const monthHeadListExport: TableUpperProps[] = [
+ { id: "용수명", title: "용수명" },
+ { id: "total", title: "계" },
+ { id: "1월", title: "1월" ,edit: true },
+ { id: "2월", title: "2월" ,edit: true },
+ { id: "3월", title: "3월" ,edit: true },
+ { id: "4월", title: "4월" ,edit: true },
+ { id: "5월", title: "5월" ,edit: true },
+ { id: "6월", title: "6월" ,edit: true },
+ { id: "7월", title: "7월" ,edit: true },
+ { id: "8월", title: "8월" ,edit: true },
+ { id: "9월", title: "9월" ,edit: true },
+ { id: "10월", title: "10월" ,edit: true },
+ { id: "11월", title: "11월" ,edit: true },
+ { id: "12월", title: "12월" ,edit: true },
+];
+
+
+
diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx
new file mode 100644
index 000000000..87e827f60
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx
@@ -0,0 +1,111 @@
+import { fetchType, getFetch, postFectch } from "@/components/lib/api";
+import { pbnstPrfmncHeadListExport, monthHeadListExport } from "./headList";
+import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
+import type { FcPrfType, PrfType } from "./type";
+import type { TableUpperProps } from "../../common/type/header";
+import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
+import toast from "react-hot-toast";
+
+const pbnstPrfmncHeadList = pbnstPrfmncHeadListExport;
+const monthHeadList = monthHeadListExport;
+
+export type pbnstPrfmncState = {
+ prfmnc: {
+ isInit: boolean;
+ pbnstPrfmncHeadList: TableUpperProps[];
+ monthHeadList: TableUpperProps[];
+ prfmncRes: FcPrfType[];
+ excelList: Number[];
+ };
+};
+
+export const pbnstPrfmncStateExport: pbnstPrfmncState = {
+ prfmnc: {
+ isInit: false,
+ pbnstPrfmncHeadList: pbnstPrfmncHeadList,
+ monthHeadList: monthHeadList,
+ prfmncRes: [],
+ excelList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
+ },
+};
+
+export type pbnstPrfmncType = pbnstPrfmncState & pbnstPrfmncActions;
+
+type pbnstPrfmncActions = {
+ prfmncHasuInit: (page: string, sggOrCity: string) => void;
+ prfmnRegData: (data: PrfType) => void;
+};
+
+const checkWrRegList = async () => {
+ const wrRegList = await getFetch("wr", `/reuseFc/pubDetailList`);
+ return wrRegList;
+};
+const hasuListFetch = async (page: string, sggOrCity: string) => {
+ const checkWrRegListRes = await checkWrRegList();
+ const rainRes = await postFectch(
+ `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`,
+ checkWrRegListRes?.fcltCds,
+ fetchType.COMMON
+ );
+
+
+ const findData = rainRes.data.map((item: pubHasuType) => {
+ const data = checkWrRegListRes?.fcPrfList.find(
+ (fclt: FcPrfType) =>
+ fclt.pbnstRuseFcltPk.substring(0, 11) === item?.bscFctCd
+ );
+ if(data !==undefined){
+ return( {
+
+ sido: item.sido,
+ gugun: item.gugun,
+ bscFctNm: item.bscFctNm,
+ bscFctCd: item.bscFctCd,
+ ruseUtztnFcltNm: data.ruseUtztnFcltNm,
+ pbnstRuseFcltPk: data.pbnstRuseFcltPk,
+ prfList: data.prfList,
+ });
+ }
+ });
+
+ return findData;
+};
+export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (
+ set: any
+) => {
+ return {
+ prfmncHasuInit: async (page: string, sggOrCity: string) => {
+ try {
+ const prfmncRes = await hasuListFetch(page, sggOrCity);
+ console.log("prfmncRes", prfmncRes);
+ return set((state: pbnstPrfmncState) => ({
+ ...state,
+ prfmnc: {
+ ...state.prfmnc,
+ prfmncRes: prfmncRes,
+ isInit: false,
+ },
+ }));
+ } catch (errorHasu) {
+ console.log(errorHasu);
+ }
+ },
+ prfmnRegData: async (data: PrfType) => {
+ try {
+ const ressponse = await postFectch(
+ "/reuseFc/pubFcPrf",
+ data,
+ fetchType.WR
+ );
+
+
+ if (ressponse.status === 200) {
+ toast.success("하수재이용 시설 실적 등록이 완료되었습니다.");
+ }
+ } catch (e) {
+ console.log(e);
+ toast.error("하수재이용 시설 실적 등록이 실패하였습니다.");
+ }
+ },
+ };
+};
diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx
new file mode 100644
index 000000000..f6d5ff43f
--- /dev/null
+++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx
@@ -0,0 +1,346 @@
+import { z } from "zod";
+import type { TableUpperProps } from "../../common/type/header";
+import { fcOperSchema } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
+
+export const PrfSchema = z.object({
+ pbnstRuseFcltFk: z.string(),
+ ym: z.string(), // 예: "202310"
+ wshwtr: z.number(),
+ coolUswtr: z.number(),
+ cleanUswtr: z.number(),
+ drwtUswtr: z.number(),
+ dltnUswtr: z.number(),
+ ithlRswtr: z.number(),
+ ithlEtcUswtr: z.number(),
+ cleanToilUswtr: z.number(),
+ resn: z.number(),
+ lndwtr: z.number(),
+ hydUswtr: z.number(),
+ rvrKeepUswtr: z.number(),
+ farmUswtr: z.number(),
+ ugwtChr: z.number(),
+ indstUswtr: z.number(),
+ regDt: z.date().default(new Date()).nullish(),
+ rgtr: z.string().nullish(),
+ mdfcnDt: z.date().default(new Date()).nullish(),
+ mdfr: z.string().nullish(),
+});
+
+export const FcPrfSchema = z.object({
+ pbnstRuseFcltPk: z.string(),
+ ruseUtztnFcltNm: z.string(),
+ fcltCpct: z.number(),
+ ruseCpct: z.number(),
+ splyExtraCpct: z.number(),
+ regDt: z.date().default(new Date()),
+ rgtr: z.string(),
+ mdfcnDt: z.date().default(new Date()),
+ mdfr: z.string(),
+ prfList: z.array(PrfSchema),
+ operList:z.array(fcOperSchema),
+ bscFctNm: z.string().nullish(),
+});
+
+export type FcPrfType = z.infer;
+export type PrfType = z.infer;
+
+export const initValInUsage = [
+ {
+ usage: "wshwtr",
+ 용수명: "세척수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "coolUswtr",
+ 용수명: "냉각수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "cleanUswtr",
+ 용수명: "청소수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "drwtUswtr",
+ 용수명: "식수대",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "dltnUswtr",
+ 용수명: "희석용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "ithlRswtr",
+ 용수명: "중수도",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "ithlEtcUswtr",
+ 용수명: "기타",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+];
+
+export const initValOutUsage = [
+ {
+ usage: "resn",
+ 용수명: "세척살수용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "cleanToilUswtr",
+ 용수명: "청소화장실용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "lndwtr",
+ 용수명: "조경용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "hydUswtr",
+ 용수명: "친수용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "ugwtChr",
+ 용수명: "지하수충전",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+ {
+ usage: "farmUswtr",
+ 용수명: "농업용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+
+ {
+ usage: "rvrKeepUswtr",
+ 용수명: "하천등유지용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+
+ {
+ usage: "indstUswtr",
+ 용수명: "공업용수",
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+ },
+];
+
+export const subTotalObj = {
+ usage: "subtotal",
+ 용수명: "소계",
+ edit: false,
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+};
+
+export const totalObj = {
+ usage: "total",
+ 용수명: "총합계",
+ edit: false,
+ total: 0,
+ "1월": 0,
+ "2월": 0,
+ "3월": 0,
+ "4월": 0,
+ "5월": 0,
+ "6월": 0,
+ "7월": 0,
+ "8월": 0,
+ "9월": 0,
+ "10월": 0,
+ "11월": 0,
+ "12월": 0,
+};
diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/excel.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/excel.tsx
new file mode 100644
index 000000000..78e0b878f
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/excel.tsx
@@ -0,0 +1,41 @@
+import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
+
+type rainSttnExcelType = {
+ bdstInfoPk: number;
+ ctpvCd: 1;
+ sggCd: 1001;
+ daddr: "string3";
+ bdstNm: "string";
+ frstArchPrmsnDt: "2025-03-25";
+ archArea: 0;
+ regDt: "2025-04-16";
+ rgtr: null;
+ mdfcnDt: "2025-04-16";
+ mdfr: null;
+};
+export const buildingExcelRainSttn = (excelList: any[]) => {
+ const excelData: string[][] = [];
+ excelList.forEach((item, index) => {
+ excelData.push([
+ String(item.cityText) ?? "",
+ String(item.sggText) ?? "",
+ String(item.bdstNm) ?? "",
+ item.operMngCd || String(item.operMngCd)===null? String(item.operMngCd) : "",
+ String(item.oilqMeasMthd) ?? "",
+ String(item.anlOperCst) ?? "",
+ String(item.dtfcltCpct) ?? "",
+ String(item.chckYmd) ?? "",
+ String(item.utztnUsgCd) ?? "",
+ String(item.totalSplyUswtrUtztnQnt) ?? "",
+ String(item.totalRuseFcltUtztnQnt) ?? "",
+ String(item.ph) ?? "",
+ String(item.trbt) ?? "",
+ String(item.grssClfg) ?? "",
+ String(item.vltnDt) ?? "",
+ String(item.vltnMttr) ?? "",
+ String(item.levyAmt) ?? "",
+ ]);
+ });
+
+ return excelData;
+};
diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx
new file mode 100644
index 000000000..f112db0bd
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx
@@ -0,0 +1,163 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+
+export const rainChkgdnHeadSttnExport: TableUpperProps[] = [
+ { id: 'order', title: "순번", mergeCell: true },
+ { id: "cityText", title: "시도", mergeCell: true },
+ { id: "sggText", title: "시군구", mergeCell: true },
+ { id: "bdstNm", title: "시설명", mergeCell: true },
+ { id: "operMngCd", title: "운영관리형태", mergeCell: true },
+ { id: "oilqMeasMthd", title: "유량측정방법", mergeCell: true },
+ { id: "anlOperCst", title: "연간운영비(원/년)", mergeCell: true },
+ { id: "dtfcltCpct", title: "빗물저류조용량(m³)", mergeCell: true },
+ { id: "chckYmd", title: "점검일", mergeCell: true },
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "totalSplyUswtrUtztnQnt", title: "연간보급수이용량(m³)" },
+ { id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" },
+ {
+ id: "ph",
+ title: "PH",
+ upName: "useQuilty",
+ upSequnce: 1,
+ type: "number",
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ upName: "useQuilty",
+ upSequnce: 2,
+ type: "number",
+ },
+ {
+ id: "grssClfg",
+ title: "총대장균군수",
+ upName: "useQuilty",
+ upSequnce: 3,
+ type: "number",
+ },
+
+ {
+ id: "vltnDt",
+ title: "부과일(위반일)",
+ upName: "feeHist",
+ upSequnce: 1,
+ type: "text",
+ },
+ {
+ id: "vltnMttr",
+ title: "위반사항",
+ upName: "feeHist",
+ upSequnce: 2,
+ type: "text",
+ },
+ {
+ id: "levyAmt",
+ title: "부과금액(천원)",
+ upName: "feeHist",
+ upSequnce: 3,
+ type: "number",
+ },
+];
+
+export const ruseSttnHeadListExport: TableUpperProps[] = [
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 },
+ { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 },
+ { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 },
+ { id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 },
+ { id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 },
+ { id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 },
+ { id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 },
+ { id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 },
+ { id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 },
+ { id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10 },
+ { id: "ruse10", title: "10월", upName: "ruseWater", upSequnce: 11 },
+ { id: "ruse11", title: "11월", upName: "ruseWater", upSequnce: 12 },
+ { id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 },
+];
+
+export const splSttnHeadListExport: TableUpperProps[] = [
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1 },
+ { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2 },
+ { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3 },
+ { id: "spl03", title: "3월", upName: "splWater", upSequnce: 4 },
+ { id: "spl04", title: "4월", upName: "splWater", upSequnce: 5 },
+ { id: "spl05", title: "5월", upName: "splWater", upSequnce: 6 },
+ { id: "spl06", title: "6월", upName: "splWater", upSequnce: 7 },
+ { id: "spl07", title: "7월", upName: "splWater", upSequnce: 8 },
+ { id: "spl08", title: "8월", upName: "splWater", upSequnce: 9 },
+ { id: "spl09", title: "9월", upName: "splWater", upSequnce: 10 },
+ {
+ id: "spl10",
+ title: "10월",
+ upName: "splWater",
+ upSequnce: 11,
+ },
+ {
+ id: "spl11",
+ title: "11월",
+ upName: "splWater",
+ upSequnce: 12,
+ },
+ {
+ id: "spl12",
+ title: "12월",
+ upName: "splWater",
+ upSequnce: 13,
+ },
+];
+
+export const rswtDetailHeadListExport: TableUpperProps[] = [
+ { id: "utztnUsgCd", title: "이용용도" },
+
+ {
+ id: "grssClfgUswtr",
+ title: "총대장균군수",
+ upName: "detailQulity",
+ upSequnce: 2,
+ },
+ {
+ id: "combResdch",
+ title: "결합잔류염소",
+ upName: "detailQulity",
+ upSequnce: 3,
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ upName: "detailQulity",
+ upSequnce: 4,
+ },
+ {
+ id: "bod",
+ title: "BOD",
+ upName: "detailQulity",
+ upSequnce: 5,
+ },
+ {
+ id: "smll",
+ title: "냄새",
+ upName: "detailQulity",
+ upSequnce: 6,
+ },
+ {
+ id: "crmty",
+ title: "색도",
+ upName: "detailQulity",
+ upSequnce: 7,
+ },
+ { id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8},
+ {
+ id: "tph",
+ title: "T-P",
+ upName: "detailQulity",
+ upSequnce: 9,
+ },
+ { id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10 },
+ {
+ id: "clIonQnt",
+ title: "염화물",
+ upName: "detailQulity",
+ upSequnce: 11,
+ },
+];
diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/index.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/index.tsx
new file mode 100644
index 000000000..9fd948856
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/index.tsx
@@ -0,0 +1,129 @@
+import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
+import { type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import { getFetch } from "@/components/lib/api";
+import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
+import type { SelectDataType } from "@common/business_components/ui";
+import { rainChkgdnHeadSttnExport, ruseSttnHeadListExport, splSttnHeadListExport } from "./headList";
+import { rainHeadNmExport, type chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
+import { buildingExcelRainSttn } from "./excel";
+
+const fcltDiv = [
+ { val: "RST", text: "중수도시설" },
+ { val: "RNB", text: "빗물이용시설" },
+];
+
+
+const rainChkgdnHeadList = rainChkgdnHeadSttnExport;
+const ruseHeadList = ruseSttnHeadListExport;
+const splHeadList = splSttnHeadListExport;
+const rainHeadNm = rainHeadNmExport
+
+const rainChk: rainChkZodType[] = [];
+
+export type rainChkSttnState = {
+ rainChkSttn: {
+ rainChkRes: rainChkZodType[];
+ fcltDiv: SelectDataType[];
+ rainChkgdnHeadList: TableUpperProps[];
+ rainHeadNm:chHeadType[];
+ ruseHeadList: TableUpperProps[];
+ splHeadList: TableUpperProps[];
+ sttnExcelList:[]
+ isInit: boolean;
+ isSttn:boolean;
+ };
+};
+
+type rainChkSttnActions = {
+ rainChkSttnInit: ( sggCd: string) => void;
+ rainChkSttnSearch: (searchTxt: string, sggCd: string) => void;
+ isRainSttn:(isSttn:boolean) => void;
+ getRainSttnExcel:(excelList:rainChkZodType[]) => void;
+};
+
+export type rainChkSttnType = rainChkSttnState & rainChkSttnActions;
+
+export const rainChkSttnStateExport: rainChkSttnState = {
+ rainChkSttn: {
+ rainChkRes: [],
+ fcltDiv: fcltDiv,
+ rainChkgdnHeadList: rainChkgdnHeadList,
+ ruseHeadList: ruseHeadList,
+ splHeadList: splHeadList,
+ rainHeadNm:rainHeadNm,
+ isInit: false,
+ sttnExcelList:[],
+ isSttn:false,
+ },
+};
+
+const initFetch = async (txt: string | undefined, sgg: string | undefined) => {
+ const rainRes = await getFetch(
+ "wr",
+ `/reuseChk/rainy/` + (txt ? `${txt}` : "2024") + (sgg ? `/${sgg}` : "/0")
+ );
+ return rainRes;
+};
+export const rainChkSttnActionsExport: (set: any) => rainChkSttnActions = (
+ set: any
+) => {
+ return {
+ rainChkSttnInit: async ( sggCd: string) => {
+ try {
+ const rainChkRes = await initFetch(undefined, sggCd);
+
+ return set((state: rainChkSttnState) => ({
+ ...state,
+ rainChkSttn: {
+ ...state.rainChkSttn,
+ rainChkRes:rainChkRes
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ rainChkSttnSearch: async (searchTxt: string, sggCd: string) => {
+ try {
+ const rainChkRes = await initFetch(searchTxt, sggCd);
+
+ return set((state: rainChkSttnState) => ({
+ ...state,
+ rainChkSttn: {
+ ...state.rainChkSttn,
+ rainChkRes:rainChkRes
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },isRainSttn :(isSttn:boolean) =>{
+ try {
+ return set((state: rainChkSttnState) => ({
+ ...state,
+ rainChkSttn: {
+ ...state.rainChkSttn,
+ isSttn:isSttn
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },getRainSttnExcel: async (excelList:rainChkZodType[]) => {
+ try {
+
+ const excelData = buildingExcelRainSttn(excelList)
+
+ return set((state: rainChkSttnState) => ({
+ ...state,
+ rainChkSttn: {
+ ...state.rainChkSttn,
+ sttnExcelList:excelData
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ }
+ };
+};
diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/excel.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/excel.tsx
new file mode 100644
index 000000000..ff104bc91
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/excel.tsx
@@ -0,0 +1,34 @@
+
+export const buildingExcelRswtSttn = (excelList: any[]) => {
+ const excelData: string[][] = [];
+ excelList.forEach((item, index) => {
+ excelData.push([
+ String(item.cityText) ?? "",
+ String(item.sggText) ?? "",
+ String(item.bdstNm) ?? "",
+ item.operMngCd===null ? "":item.operMngCd,
+ String(item.anlOperCst) ?? "",
+ String(item.prcsCpct) ?? "",
+ item.spwtPositn===null ? "":item.spwtPositn,
+ item.chckYmd ?? "",
+ String(item.utztnUsgCd) ?? "",
+ String(item.splyUswtrUtztnQnt) ?? "",
+ String(item.ruseFcltUtztnQnt) ?? "",
+ String(item.grssClfgUswtr) ?? "",
+ String(item.combResdch) ?? "",
+ String(item.trbt) ?? "",
+ String(item.bod) ?? "",
+ String(item.smll) ?? "",
+ String(item.tn) ?? "",
+ String(item.tph) ?? "",
+ String(item.ph) ?? "",
+ String(item.clIonQnt) ?? "",
+ String(item.vltnDt) ?? "",
+ String(item.vltnMttr) ?? "",
+ String(item.levyAmt) ?? "",
+ ]);
+ });
+
+ return excelData;
+ };
+
\ No newline at end of file
diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx
new file mode 100644
index 000000000..f67e98101
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx
@@ -0,0 +1,142 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+
+export const rswtChkSttnHeadListExport: TableUpperProps[] = [
+ { id: "order", title: "순번", rowSpan: true },
+ { id: "cityText", title: "시도", rowSpan: true },
+ { id: "sggText", title: "시군구", rowSpan: true },
+ { id: "bdstNm", title: "시설명", rowSpan: true },
+ { id: "operMngCd", title: "운영관리형태", rowSpan: true },
+ { id: "anlOperCst", title: "연간운영비(원/년)", rowSpan: true },
+ { id: "prcsCpct", title: "처리용량(m³)", rowSpan: true },
+ { id: "spwtPositn", title: "채수지점", rowSpan: true },
+ { id: "chckYmd", title: "점검일", rowSpan: true },
+ { id: "utztnUsgCd", title: "이용용도" },
+ { id: "splyUswtrUtztnQnt", title: "연간보급수이용량(m³)", type: "number" },
+ { id: "ruseFcltUtztnQnt", title: "연간중수도이용량(m³)", type: "number" },
+
+ {
+ id: "grssClfgUswtr",
+ title: "총대장균군수",
+ upName: "useQuilty",
+ upSequnce: 1,
+ type: "number",
+ },
+ {
+ id: "combResdch",
+ title: "결합잔류염소",
+ upName: "useQuilty",
+ upSequnce: 2,
+ type: "number",
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ upName: "useQuilty",
+ upSequnce: 3,
+ type: "number",
+ },
+ {
+ id: "bod",
+ title: "BOD",
+ upName: "useQuilty",
+ upSequnce: 4,
+ type: "number",
+ },
+ {
+ id: "smll",
+ title: "냄새",
+ upName: "useQuilty",
+ upSequnce: 5,
+ type: "number",
+ },
+ {
+ id: "crmty",
+ title: "색도",
+ upName: "useQuilty",
+ upSequnce: 6,
+ type: "number",
+ },
+ { id: "tn", title: "T-N", upName: "useQuilty", upSequnce: 7, type: "number" },
+ {
+ id: "tph",
+ title: "T-P",
+ upName: "useQuilty",
+ upSequnce: 8,
+ type: "number",
+ },
+ { id: "ph", title: "PH", upName: "useQuilty", upSequnce: 9, type: "number" },
+ {
+ id: "clIonQnt",
+ title: "염화물",
+ upName: "useQuilty",
+ upSequnce: 10,
+ type: "number",
+ },
+
+ {
+ id: "vltnDt",
+ title: "부과일(위반일)",
+ upName: "feeHist",
+ upSequnce: 1,
+ type: "text",
+ },
+ {
+ id: "vltnMttr",
+ title: "위반사항",
+ upName: "feeHist",
+ upSequnce: 2,
+ type: "text",
+ },
+ {
+ id: "levyAmt",
+ title: "부과금액(천원)",
+ upName: "feeHist",
+ upSequnce: 3,
+ type: "number",
+ },
+];
+
+export const rswtDetailSttnHeadListExport: TableUpperProps[] = [
+ { id: "utztnUsgCd", title: "이용용도" },
+
+ {
+ id: "grssClfgUswtr",
+ title: "총대장균군수",
+ upName: "detailQulity",
+ upSequnce: 2,
+ },
+ {
+ id: "combResdch",
+ title: "결합잔류염소",
+ upName: "detailQulity",
+ upSequnce: 3,
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ upName: "detailQulity",
+ upSequnce: 4,
+ },
+ { id: "bod", title: "BOD", upName: "detailQulity", upSequnce: 5 },
+ {
+ id: "smll",
+ title: "냄새",
+ upName: "detailQulity",
+ upSequnce: 6,
+ },
+ {
+ id: "crmty",
+ title: "색도",
+ upName: "detailQulity",
+ upSequnce: 7,
+ },
+ { id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8},
+ { id: "tph", title: "T-P", upName: "detailQulity", upSequnce: 9 },
+ { id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10 },
+ {
+ id: "clIonQnt",
+ title: "염화물",
+ upName: "detailQulity",
+ upSequnce: 11,
+ },
+];
diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/index.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/index.tsx
new file mode 100644
index 000000000..b985cd944
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/index.tsx
@@ -0,0 +1,107 @@
+import { rswtHeadNmExport } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList";
+import { rswtChkSttnHeadListExport, rswtDetailSttnHeadListExport } from "./headList";
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
+import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
+import { getFetch } from "@/components/lib/api";
+import { buildingExcelRswtSttn } from "./excel";
+
+const rswtChkHeadList = rswtChkSttnHeadListExport;
+const rswtDetailHeadList = rswtDetailSttnHeadListExport;
+const rswtHeadNm = rswtHeadNmExport;
+
+
+export type rswtChkSttnState = {
+ rswtChkSttn: {
+ rswtChkSttnHeadList: TableUpperProps[];
+ rswtDetailSttnHeadList: TableUpperProps[];
+ rswtSttnHeadNm: chHeadType[];
+ sttnExcelList: [];
+ rswtChkRes: rswtChkZodType[];
+ isInit: boolean;
+ isSttn: boolean;
+ };
+};
+
+type rswtChkSttnActions = {
+ rswtChkSttnInit: ( sggCd: string) => void;
+ isRswtSttn: (isSttn:boolean) => void;
+ getRswtSttnExcel:(excelList:rswtChkZodType[]) => void;
+
+};
+
+export type rswtChkSttnType = rswtChkSttnState & rswtChkSttnActions;
+
+export const rswtChkStateExport: rswtChkSttnState = {
+ rswtChkSttn: {
+ rswtChkSttnHeadList: rswtChkHeadList,
+ rswtDetailSttnHeadList: rswtDetailHeadList,
+ rswtSttnHeadNm: rswtHeadNm,
+ sttnExcelList: [],
+ rswtChkRes: [],
+ isInit: false,
+ isSttn:false,
+ },
+};
+
+const initFetch = async (year: string | undefined, sgg: string | undefined) => {
+ const rswtChkRes = await getFetch(
+ "wr",
+ `/reuseChk/reuseWater/` +
+ (year ? `${year}` : "2024") +
+ (sgg ? `/${sgg}` : "/0")
+ );
+ return rswtChkRes;
+};
+
+
+export const rswtChkSttnActionsExport: (set: any) => rswtChkSttnActions = (
+ set: any
+) => {
+ return {
+ rswtChkSttnInit: async ( sggCd: string) => {
+ try {
+ const rswtChkRes = await initFetch("2024", sggCd);
+ return set((state: rswtChkSttnState) => ({
+ ...state,
+ rswtChkSttn: {
+ ...state.rswtChkSttn,
+ rswtChkRes: rswtChkRes,
+ isInit: false,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },isRswtSttn :(isSttn:boolean) =>{
+ try {
+ return set((state: rswtChkSttnState) => ({
+ ...state,
+ rswtChkSttn: {
+ ...state.rswtChkSttn,
+ isSttn:isSttn
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },getRswtSttnExcel: async (excelList:rswtChkZodType []) => {
+ try {
+
+ const excelData = buildingExcelRswtSttn(excelList)
+
+ return set((state: rswtChkSttnState) => ({
+ ...state,
+ rswtChkSttn: {
+ ...state.rswtChkSttn,
+ sttnExcelList:excelData
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ }
+
+
+ };
+};
diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx
new file mode 100644
index 000000000..113a35289
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx
@@ -0,0 +1,24 @@
+export const excelPrfmncSttnParsing = (
+ data: any[]
+): string[][] => {
+ const excelExportData: string[][] = [];
+ data.forEach((item) => {
+ excelExportData.push([
+ item.용수명,
+ item.total,
+ item["1월"],
+ item["2월"],
+ item["3월"],
+ item["4월"],
+ item["5월"],
+ item["6월"],
+ item["7월"],
+ item["8월"],
+ item["9월"],
+ item["10월"],
+ item["11월"],
+ item["12월"],
+ ]);
+ });
+ return excelExportData;
+};
\ No newline at end of file
diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/headList.tsx
new file mode 100644
index 000000000..d04ef7b20
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/headList.tsx
@@ -0,0 +1,59 @@
+import { z } from "zod";
+import type { TableUpperProps } from "../../ruseFcltMng/fcltReg/rainReg";
+
+export const pbnstPrfmncSttnHeadListExport: TableUpperProps[] = [
+ {
+ id: "number",
+ title: "No",
+ rowSpan: 2,
+ row: 0
+ },
+ {
+ id: "sido",
+ title: "시도",
+ rowSpan: 2,
+ row: 0
+ },
+ {
+ id: "gugun",
+ title: "시군구",
+ rowSpan: 2,
+ row: 0
+ },
+ {
+ id: "bscFctNm",
+ title: "시설명",
+ rowSpan: 2,
+ row: 0
+ },
+ {
+ id: "ruseUtztnFcltNm",
+ title: "재이용시설명",
+ rowSpan: 2,
+ row: 0
+ },
+
+]
+
+export const pbnstYearHeadListExport: TableUpperProps[] = [
+ {
+ title: "년도",
+ colSpan: 3,
+ row: 0
+ },
+ {
+ id: "total",
+ title: "계",
+ row: 1
+ },
+ {
+ id: "inUsage",
+ title: "장내용수",
+ row: 1
+ },
+ {
+ id: "outUsage",
+ title: "장외용수",
+ row: 1
+ },
+]
diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx
new file mode 100644
index 000000000..b513085ae
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx
@@ -0,0 +1,216 @@
+import { fetchType, getFetch, postFectch } from "@/components/lib/api";
+import type { TableUpperProps } from "../../common/type/header";
+import { pbnstPrfmncSttnHeadListExport, pbnstYearHeadListExport } from "./headList";
+import type { FcPrfType, PrfType } from "../../prfmncReg/pbnstPrfmncReg/type";
+import type { pubHasuType, selectLabel } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
+import type { ReturnType } from "@common/business_components";
+
+type pbnstPrfmncSttnActions = {
+ tableHeadMaker: (startYear: number, endYear: number) => void;
+ pbnstPrfmncInit: (page: string, sggOrCity: string) => void;
+ pbnstPrfmncSearch: (returnType: ReturnType, swtrmtFcltNm: string, fromDate: string, toDate: string) => void;
+}
+
+const pbnstPrfmncRes: PrfType[] = [];
+const prfmncRes: FcPrfType[] = [];
+
+export type pbnstPrfmncSttnState = {
+ pbnstPrfmncSttn: {
+ pbnstPrfHeadList: TableUpperProps[];
+ pbnstPrfmncRes: PrfType[];
+ prfmncRes: any[];
+ isInit: boolean;
+ rawData: any[];
+ selectYearList: selectLabel[]
+ }
+}
+
+export type pbnstPrfmncSttnType = pbnstPrfmncSttnState & pbnstPrfmncSttnActions;
+
+export const pbnstPrfmncSttnExport: pbnstPrfmncSttnState = {
+ pbnstPrfmncSttn: {
+ pbnstPrfHeadList: [...pbnstPrfmncSttnHeadListExport],
+ pbnstPrfmncRes: pbnstPrfmncRes,
+ prfmncRes: prfmncRes,
+ isInit: false,
+ rawData: [],
+ selectYearList: []
+ }
+}
+
+const checkWrRegList = async () => {
+ const wrRegList = await getFetch("wr", `/reuseFc/pubDetailList`);
+ return wrRegList;
+};
+const hasuListFetch = async (page: string, sggOrCity: string) => {
+ const checkWrRegListRes = await checkWrRegList();
+ const rainRes = await postFectch(
+ `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`,
+ checkWrRegListRes?.fcltCds,
+ fetchType.COMMON
+ );
+ const data = checkWrRegListRes.fcPrfList.map((item: FcPrfType) => {
+ const findData = rainRes.data.find(
+ (fclt: pubHasuType) =>
+ fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11)
+ );
+ return {
+ sido: findData?.sido,
+ gugun: findData?.gugun,
+ bscFctNm: findData?.bscFctNm,
+ ruseUtztnFcltNm: item.ruseUtztnFcltNm,
+ pbnstRuseFcltPk: item.pbnstRuseFcltPk,
+ };
+ });
+ return data;
+}
+
+export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions = (
+ set: any
+) => {
+ return {
+ tableHeadMaker: (startYear: number, endYear: number) => {
+ let yearHeader: TableUpperProps[] = [...pbnstPrfmncSttnHeadListExport];
+ const selectList = [] as unknown as selectLabel[]
+ for (let i = startYear; i <= endYear; i++) {
+ const yearHead = JSON.parse(JSON.stringify(pbnstYearHeadListExport));
+ if (yearHead) {
+ yearHead.forEach((item: { id?: string; }) => {
+ if (item.id) {
+ item.id = i + item.id;
+
+ }
+
+ })
+ if (yearHead[0])
+ yearHead[0].title = i + "년도"
+ }
+ yearHeader = [...yearHeader, ...yearHead]
+ selectList.push({ text: i + "년도", val: String(i) })
+ }
+ set((state: pbnstPrfmncSttnState) => {
+ return {
+ ...state,
+ pbnstPrfmncSttn: {
+ ...state.pbnstPrfmncSttn,
+ pbnstPrfHeadList: [...yearHeader],
+ selectYearList: selectList
+ },
+ };
+ });
+ },
+ pbnstPrfmncInit: async (page: string, sggOrCity: string) => {
+ try {
+ const prfmncRes = await hasuListFetch(page, sggOrCity);
+ return set((state: pbnstPrfmncSttnState) => ({
+ ...state,
+ pbnstPrfmncSttn: {
+ ...state.pbnstPrfmncSttn,
+ prfmncRes: prfmncRes,
+ isInit: true,
+ },
+ }));
+ } catch (e) {
+ console.log(e)
+ }
+ },
+ pbnstPrfmncSearch: async (returnType: ReturnType, swtrmtFcltNm: string, fromDate: string, toDate: string) => {
+ let searchUrl = "";
+ if (returnType.sigunValue !== "0") {
+ if (swtrmtFcltNm !== "") {
+ searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sigunValue}/0/1/SW${'/' + swtrmtFcltNm}`;
+ } else {
+ searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sigunValue}/0/1/SW`;
+ }
+ } else {
+ if (swtrmtFcltNm !== "") {
+ searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sidoValue}/0/1/SW${'/' + swtrmtFcltNm}`;
+ } else {
+ searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sidoValue}/0/1/SW`;
+ }
+ }
+
+ const pbnstRes = await getFetch(
+ fetchType.COMMON,
+ searchUrl
+ );
+
+ const bscFctCdList = pbnstRes.map((item: any) => {
+ return item.bscFctCd;
+ })
+ const res = await postFectch(
+ `/reuseFc/pubDetailList/${fromDate}/${toDate}`,
+ bscFctCdList,
+ `wr`,
+ )
+ let inUsageSum = 0;
+ let outUsageSum = 0;
+ let usageSum = 0;
+ let year = "";
+ const yearsData = []
+
+ res.data.forEach((item) => {
+ if (item.prfList.length === 0) {
+ const year = ""; // 연도 정보가 없으면 빈 문자열, 필요시 item에서 추출
+ const yearVal = { year: year, pbnstRuseFcltPk: item.pbnstRuseFcltPk ?? "", ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" };
+ yearVal[year + "inUsage"] = 0;
+ yearVal[year + "outUsage"] = 0;
+ yearVal[year + "total"] = 0;
+ yearsData.push(yearVal);
+ }
+ item.prfList.forEach((acc) => {
+ year = acc.ym?.substring(0, 4) ?? "";
+ inUsageSum =
+ (acc.wshwtr ?? 0) +
+ (acc.coolUswtr ?? 0) +
+ (acc.cleanUswtr ?? 0) +
+ (acc.drwtUswtr ?? 0) +
+ (acc.dltnUswtr ?? 0) +
+ (acc.ithlRswtr ?? 0) +
+ (acc.ithlEtcUswtr ?? 0) +
+ (acc.cleanToilUswtr ?? 0) +
+ (acc.resn ?? 0);
+ outUsageSum =
+ (acc.lndwtr ?? 0) +
+ (acc.hydUswtr ?? 0) +
+ (acc.ugwtChr ?? 0) +
+ (acc.farmUswtr ?? 0) +
+ (acc.rvrKeepUswtr ?? 0) +
+ (acc.indstUswtr ?? 0);
+ const yearData = yearsData.find(
+ (yearItem) =>
+ yearItem.year === year &&
+ yearItem.pbnstRuseFcltPk == acc.pbnstRuseFcltPk
+ );
+
+ if (yearData) {
+ yearData[year + "inUsage"] += inUsageSum;
+ yearData[year + "outUsage"] += outUsageSum;
+ yearData[year + "total"] += (inUsageSum + outUsageSum);
+ } else {
+ const yearVal = { year: year, pbnstRuseFcltPk: acc.pbnstRuseFcltFk, ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" };
+ yearVal[year + "inUsage"] = inUsageSum;
+ yearVal[year + "outUsage"] = outUsageSum;
+ yearVal[year + "total"] = inUsageSum + outUsageSum;
+ yearsData.push(yearVal);
+ }
+ });
+ });
+ const resData: any[] = []
+ pbnstRes.forEach((acc) => {
+ let data = yearsData.find((item) => item.pbnstRuseFcltPk.substring(0, 11) === acc.bscFctCd)
+ if (data) {
+ resData.push({ ...acc, ...data })
+ }
+ })
+ return set((state: pbnstPrfmncSttnState) => ({
+ ...state,
+ pbnstPrfmncSttn: {
+ ...state.pbnstPrfmncSttn,
+ prfmncRes: resData,
+ rawData: res.data
+ },
+ }));
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/publicReuseFaciltyInsert/index.tsx b/apps/wr/app/store/publicReuseFaciltyInsert/index.tsx
deleted file mode 100644
index 131132b85..000000000
--- a/apps/wr/app/store/publicReuseFaciltyInsert/index.tsx
+++ /dev/null
@@ -1,178 +0,0 @@
-import type { TableUpperProps } from "../rainReuseFacilityInsert";
-
-export type TableProps = {
- id: string;
- title: string;
-}
-
-export type selectLabel={
- text:string,
- val:string
-}
-
-
-type publicReuseFacilityData = {
- sido: string,
- sigungo: string,
- facilityName: string,
- location: string,
- locationgubun: string,
- facilityCapacity: string,
- yn?: string,
- authoDay?: string,
- area?: string,
- reuse?: string,
- register?: string
-
-
-}
-type pubMngFacData = {
- mng: string,
- subCo: string,
- startDay: string,
- endDay: string,
-}
-const selectLabel:selectLabel[]=[
- {text:'test',val:'1'}
-]
-
-
-const pubFacHeadList:TableProps[] = [
- { id: "sido", title: "시도"},
- { id: "sigungo", title: "시군구"},
- { id: "facilityName", title: "시설명"},
- { id: "location", title: "위치"},
- { id: "locationgubun", title: "지역구분"},
- { id: "facilityCapacity", title: "시설용량"},
- { id: "yn", title: '재이용여부' },
- { id: "authoDay", title: '등록여부'}];
-
-
- const pubMngUpHeadList:TableUpperProps[] = [
- { id: "mng", title: "운영방식"},
- { id: "subCo", title: "대행업체"},
- { id: "startDay", title: "시작일", upName:'upChangeRe' , upSequnce:1 },
- { id: "endDay", title: "종료일", upName:'upChangeRe' , upSequnce:2 },
- ];
- const date = new Date()
- const pubMngFacData:pubMngFacData[] = [
- { mng:"자체운영", subCo:"-",startDay: '2024-11-11' ,endDay:'2024-11-20'},
- { mng:"자체운영", subCo:"한국수자원공사",startDay: '2022-11-11' ,endDay:'2024-09-13'},
- { mng:"자체운영", subCo:"스타벅스",startDay: '2023-11-11' ,endDay:'2024-02-19'},
- ];
- const publicReuseFacilityData:publicReuseFacilityData[] = [
- {
- sido: "서울",
- sigungo: "강남구",
- facilityName: "난지",
- location: "경기도 고양시 덕양구 대차로 4가",
- locationgubun: "500",
- facilityCapacity: "800,000",
- reuse: "Y",
- register: "Y"
- },
- {
- sido: "서울",
- sigungo: "강남구",
- facilityName: "난지",
- location: "경기도 고양시 덕양구 대차로 4가",
- locationgubun: "500",
- facilityCapacity: "800,000",
- reuse: "Y",
- register: "Y"
- },
- {
- sido: "서울",
- sigungo: "강남구",
- facilityName: "난지",
- location: "경기도 고양시 덕양구 대차로 4가",
- locationgubun: "500",
- facilityCapacity: "800,000",
- yn: "Y",
- authoDay: "2012",
- area:"123"
- },
-]
-
-
-const erctUswtrCd:selectLabel[]=[
- {text:'처리장연계',val:'1_erct'},
- {text:'자체/연계',val:'2_erct'},
- {text:'자체처리',val:'3_erct'},
-]
-
-const cyclCd :selectLabel[]= [
- { text: "1차", val: "1_cyc" },
- { text: "2차", val: "2_cyc" },
- ];
- const seCd :selectLabel[] = [
- { text: "신규", val: "1_Se" },
- { text: "진행", val: "2_Se" },
- ];
- const buseCd :selectLabel[]= [
- { text: "재정", val: "1_bus" },
- { text: "만루", val: "2_bus" },
- ];
- const rprcsCd :selectLabel[] = [
- { text: "물리적처리", val: "1_rprc" },
- { text: "생물학적처리", val: "2_rprc" },
- ];
- const buseMet :selectLabel[] = [
- { text: "재정", val: "1_busemet" },
- { text: "민간투자", val: "2_busemet" },
- { text: "자체", val: "3_busemet" },
- ];
- const rprcLoCd :selectLabel[] = [
- { text: "내부", val: "1_rprc" },
- { text: "외부", val: "2_rprc" },
- ];
-
-export type pubFacState = {pubFac:{
- isInit: boolean;
- pubFacHeadList: TableProps[];
- pubMngUpHeadList:TableUpperProps[]
- publicReuseFacilityData: publicReuseFacilityData[];
- selectLabel:selectLabel[];
- pubMngFacData:pubMngFacData[];
- erctUswtrCd:selectLabel[];
- cyclCd:selectLabel[];
- seCd:selectLabel[];
- buseCd :selectLabel[]
- rprcsCd :selectLabel[]
- buseMet :selectLabel[]
- rprcLoCd:selectLabel[]
-}}
-type pubFacActions = {
- decrementList: () => void
-}
-
-export type pubFacType = pubFacState & pubFacActions;
-
-export const pubFacStateExport:pubFacState= {pubFac:{
- isInit:false,
- pubFacHeadList: pubFacHeadList,
- pubMngUpHeadList:pubMngUpHeadList,
- publicReuseFacilityData: publicReuseFacilityData,
- selectLabel:selectLabel,
- pubMngFacData:pubMngFacData,
- erctUswtrCd:erctUswtrCd,
- cyclCd:cyclCd,
- seCd:seCd,
- buseCd:buseCd,
- rprcsCd:rprcsCd,
- buseMet:buseMet,
- rprcLoCd:rprcLoCd
-}}
-export const pubFacActionsExport:(set:any)=>pubFacActions=(set: any) => {
- return {
- decrementList:()=>set(
- (state:pubFacState) => {
- return (
- {pubFac:{
- pubFacheadList: state.pubFac.pubFacHeadList,
- publicReuseFacilityUper:
- state.pubFac.publicReuseFacilityData.slice(0, state.pubFac.publicReuseFacilityData.length - 1)
- }})}
- )
- }
-}
diff --git a/apps/wr/app/store/rainReuseFacilityInsert/index.tsx b/apps/wr/app/store/rainReuseFacilityInsert/index.tsx
deleted file mode 100644
index 0fd5194f9..000000000
--- a/apps/wr/app/store/rainReuseFacilityInsert/index.tsx
+++ /dev/null
@@ -1,134 +0,0 @@
-
-export type TableUpperProps = {
- id: string;
- title: string;
- upName?: string;
- upSequnce?: number;
-}
-export type rainFacOfType = {
- sido: string,
- sigungo: string,
- facilityName: string,
- location: string,
- locationgubun: string,
- firstConstructionPermission:string,
- facilityCapacity: string,
- buildingArea:string,
- yn?: string,
- permissionDay:string;
- authoDay?: string,
- area?: string,
- reuse?: string,
- register?: string,
- legalTargetYn:string,
-}
-
-export const upHeadList:TableUpperProps[] = [
- { id: "sido", title: "시도"},
- { id: "sigungo", title: "시군구"},
- { id: "facilityName", title: "시설명"},
- { id: "location", title: "위치"},
- { id: "locationgubun", title: "지역구분"},
- { id: "facilityCapacity", title: "시설용량"},
- { id: "yn", title: '여부', upName:'upChangeRe' , upSequnce:1 },
- { id: "authoDay", title: '허가일',upName:'upChangeRe', upSequnce:2 },
- { id: "area", title: '면적' ,upName:'upChangeRe',upSequnce:3 }];
-
-const rainOfObject:rainFacOfType[] = [
- {
- sido: "서울",
- sigungo: "종로구",
- facilityName: "그랑서울",
- location: "종로 33",
- locationgubun: "업무시설",
- firstConstructionPermission : '2024-10-10',
- buildingArea: "50",
- facilityCapacity: "800,000",
- reuse: "Y",
- permissionDay:'2024-10-10',
- register: "Y",
- legalTargetYn:"Y"
- },
- {
- sido: "서울",
- sigungo: "종로구",
- facilityName: "그랑서울",
- location: "종로 33",
- locationgubun: "업무시설",
- firstConstructionPermission : '2024-10-10',
- buildingArea: "50",
- facilityCapacity: "800,000",
- reuse: "Y",
- permissionDay:'2024-10-10',
- register: "Y",
- legalTargetYn:"Y"
- },
- {
- sido: "서울",
- sigungo: "종로구",
- facilityName: "그랑서울",
- location: "종로 33",
- locationgubun: "업무시설",
- firstConstructionPermission : '2024-10-10',
- buildingArea: "50",
- facilityCapacity: "800,000",
- reuse: "Y",
- permissionDay:'2024-10-10',
- register: "Y",
- legalTargetYn:"Y"
- },
-]
-
-
-export type selectArray ={
- text:string,
- val:string
-
-}
-
-export const selectClass ="w-full h-full text-2xl";
-const selectHomeWater = [
- { text: '집수면', val: "1" },
- { text: "종류", val: "2" },
- ];
-
- const selectYN= [
- { text: 'Y', val: "1" },
- { text: 'N', val: "2" },
- ];
-
-export type rainFacState ={ rain:{
- isInit: boolean;
- upHeadList: TableUpperProps[];
- rainOfObject: rainFacOfType[];
- selectHomeWater:selectArray[];
- selectYN:selectArray[];
-}}
-type rainFacSActions = {
- decrementList: () => void
-}
-
-export type rainFacType = rainFacState & rainFacSActions;
-
-export const rainFacStateExport:rainFacState= {rain:{
- isInit:false,
- upHeadList: upHeadList,
- rainOfObject: rainOfObject,
- selectHomeWater:selectHomeWater,
- selectYN:selectYN
-
-
-}}
-export const rainFacActionsExport:(set:any)=>rainFacSActions=(set: any) => {
- return {
- decrementList:()=>set(
- (state:rainFacState) => {
- return (
- {rain:{
- upHeadList: state.rain.upHeadList,
- rainOfObject:
- state.rain.rainOfObject.slice(0, state.rain.rainOfObject.length - 1)
- }})}
- )
- }
-}
diff --git a/apps/wr/app/store/rswtrReuseFaciltyInsert/index.tsx b/apps/wr/app/store/rswtrReuseFaciltyInsert/index.tsx
deleted file mode 100644
index b2621631b..000000000
--- a/apps/wr/app/store/rswtrReuseFaciltyInsert/index.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import { upHeadList, type rainFacOfType, type selectArray, type TableUpperProps } from "../rainReuseFacilityInsert";
-
-
-const rswtOfObject:rainFacOfType[] = [
- {
- sido: "서울",
- sigungo: "종로구",
- facilityName: "그랑서울",
- location: "종로 33",
- locationgubun: "업무시설",
- firstConstructionPermission : '2024-10-10',
- buildingArea: "50",
- facilityCapacity: "800,000",
- reuse: "Y",
- permissionDay:'2024-10-10',
- register: "Y",
- legalTargetYn:"Y"
- },
- {
- sido: "서울",
- sigungo: "종로구",
- facilityName: "그랑서울",
- location: "종로 33",
- locationgubun: "업무시설",
- firstConstructionPermission : '2024-10-10',
- buildingArea: "50",
- facilityCapacity: "800,000",
- reuse: "Y",
- permissionDay:'2024-10-10',
- register: "Y",
- legalTargetYn:"Y"
- },
- {
- sido: "서울",
- sigungo: "종로구",
- facilityName: "그랑서울",
- location: "종로 33",
- locationgubun: "업무시설",
- firstConstructionPermission : '2024-10-10',
- buildingArea: "50",
- facilityCapacity: "800,000",
- reuse: "Y",
- permissionDay:'2024-10-10',
- register: "Y",
- legalTargetYn:"Y"
- },
-]
-
-
-const selectHomeWater = [
- { text: '집수면', val: "1" },
- { text: "종류", val: "2" },
- ];
-
- const selectYN= [
- { text: 'Y', val: "1" },
- { text: 'N', val: "2" },
- ];
-
-export type rswtFacState ={ rswt:{
- isInit: boolean;
- upHeadList: TableUpperProps[];
- rswtOfObject: rainFacOfType[];
- selectHomeWater:selectArray[];
- selectYN:selectArray[];
-}}
-type rswtFacSActions = {
- decrementList: () => void
-}
-
-export type rswtFacType = rswtFacState & rswtFacSActions;
-
-export const rswtFacStateExport:rswtFacState= {rswt:{
- isInit:false,
- upHeadList: upHeadList,
- rswtOfObject: rswtOfObject,
- selectHomeWater:selectHomeWater,
- selectYN:selectYN
-
-
-}}
-export const rswtFacActionsExport:(set:any)=>rswtFacSActions=(set: any) => {
- return {
- decrementList:()=>set(
- (state:rswtFacState) => {
- return (
- {rain:{
- upHeadList: state.rswt.upHeadList,
- rainOfObject:
- state.rswt.rswtOfObject.slice(0, state.rswt.rswtOfObject.length - 1)
- }})}
- )
- }
-}
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/bdstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/bdstReg/index.tsx
new file mode 100644
index 000000000..931cd1305
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/bdstReg/index.tsx
@@ -0,0 +1,200 @@
+import { getFetch } from "@/components/lib/api";
+import { TEST_UUID, type customRainBdst } from "../rainReg";
+import type { customHtdflBdst } from "../htdflReg";
+import type { customRswtBdst } from "../rswtReg";
+import type { TableUpperProps } from "@/app/store/common/type/header";
+
+
+ const moUpHeadList: TableUpperProps[] = [
+ { id: "cityText", title: "시도" },
+ { id: "sggText", title: "시군구" },
+ { id: "bdstNm", title: "시설명" },
+ { id: "daddr", title: "위치" },
+ { id: "frstArchPrmsnDt", title: "최초건축허가일" },
+ { id: "archArea", title: "건축면적", },
+ ];
+
+
+ const bdstChgHeadList: TableUpperProps[] = [
+ { id: "bdstChgNm", title: "구분" },
+ { id: "archChgPrmsnDt", title: "허가일" },
+ { id: "archChgArea", title: "변경면적" },
+
+ ];
+
+
+
+const bdstBase:any[] = [];
+
+
+const isRainBdst = (data: any): data is customRainBdst=> {
+ return data.reuseBuilding?.[0]?.rainyObj !== undefined;
+}
+
+const isHtdflBdst = (data: any): data is customHtdflBdst=> {
+ return data.reuseBuilding?.[0]?.htdflObj !== undefined;
+}
+
+const isRswtBdst = (data: any): data is customRswtBdst =>{
+ return data.reuseBuilding?.[0]?.rswtrObj !== undefined;
+}
+
+
+
+ export const makeRstr =(data:customRainBdst|customHtdflBdst|customRswtBdst) =>{
+ data.rgtr = TEST_UUID;
+
+ let chData
+ if(isRainBdst(data)){
+ chData = data.reuseBuilding.map((item) => ({
+ ...item,
+ rgtr : TEST_UUID,
+ rainyObj:{
+ ...item.rainyObj,
+ rgtr:TEST_UUID
+ }
+ }));
+
+ data.reuseBuilding=chData;
+ }else if(isHtdflBdst(data)){
+ chData = data.reuseBuilding.map((item) => ({
+ ...item,
+ rgtr : TEST_UUID,
+ htdflObj:{
+ ...item.htdflObj,
+ rgtr:TEST_UUID
+ }
+ }));
+
+ data.reuseBuilding=chData;
+ }else if (isRswtBdst(data)){
+ chData = data.reuseBuilding.map((item) => ({
+ ...item,
+ rgtr : TEST_UUID,
+ rswtrObj:{
+ ...item.rswtrObj,
+ rgtr:TEST_UUID
+ }
+ }));
+ data.reuseBuilding=chData;
+ }
+
+ if(data?.chgBuilding.length>0){
+ const chRgtr = data.chgBuilding.map((item) =>({...item, rgtr:TEST_UUID, mdfr: item.mdfr ?? null }))
+ data.chgBuilding =chRgtr;
+ }
+ return data;
+
+ }
+
+ export const makeMdfr =(data:customRainBdst|customHtdflBdst|customRswtBdst) =>{
+ data.mdfr = TEST_UUID;
+ let chData
+ if(isRainBdst(data)){
+ chData = data.reuseBuilding.map((item) => ({
+ ...item,
+ mdfr : TEST_UUID,
+ rainyObj:{
+ ...item.rainyObj,
+ mdfr:TEST_UUID
+ }
+ }));
+ if(data?.chgBuilding.length>0){
+ const chRgtr = data.chgBuilding.map((item) =>({...item, rgtr:TEST_UUID, mdfr: item.mdfr ?? null }))
+ data.chgBuilding =chRgtr;
+ }
+
+ data.reuseBuilding=chData
+ }else if(isHtdflBdst(data)){
+ chData = data.reuseBuilding.map((item) => ({
+ ...item,
+ mdfr : TEST_UUID,
+ htdflObj:{
+ ...item.htdflObj,
+ mdfr:TEST_UUID
+ }
+ }));
+ data.reuseBuilding=chData;
+ }else if (isRswtBdst(data)){
+ chData = data.reuseBuilding.map((item) => ({
+ ...item,
+ mdfr : TEST_UUID,
+ rswtrObj:{
+ ...item.rswtrObj,
+ mdfr:TEST_UUID
+ }
+ }));
+ data.reuseBuilding=chData;
+ }
+
+ if(data?.chgBuilding.length>0){
+ const chMdfr = data.chgBuilding.map((item) =>({...item, mdfr:TEST_UUID, archChgArea: item.archChgArea ?? '' }))
+ data.chgBuilding =chMdfr;
+ }
+
+ return data;
+
+ }
+
+export type bdstFulType = bdstState & bdstActions;
+
+
+export type bdstState = {
+ bdst: {
+ bdstBase: any[];
+ moUpHeadList:TableUpperProps[]
+ bdstChgHeadList:TableUpperProps[]
+ };
+};
+
+type bdstActions = {
+ findBdst: (sggCd:string, searchTxt:string, flag:string) => void ;
+ };
+
+
+ const findBdstInfo = async(sggCd:string, searchTxt:string ,flg:string)=>{
+ return await getFetch('wr', `/reuseFc/building/${flg}/${sggCd}`+(searchTxt?`/${searchTxt}`:'' ))
+
+ }
+
+export const bdstStateExport: bdstState = {
+ bdst: {
+ bdstBase: bdstBase, // Updated to match the array type
+ moUpHeadList:moUpHeadList,
+ bdstChgHeadList:bdstChgHeadList,
+ },
+};
+
+export const bdstActionsExport: (set: any) => bdstActions = (
+ set: any
+) => {
+ return {
+
+ findBdst: async(sggCd:string, searchTxt:string ,flg:string ) =>{
+ try{
+
+ const bdst = await findBdstInfo(sggCd, searchTxt, flg);
+ const makeBdst = bdst.map((item:any) => {
+ return {
+ ...item,
+ reuseBuilding:[]
+ };
+ })
+ return set((state:bdstState) =>({
+ ...state,
+ bdst:{
+ ...state.bdst,
+ bdstBase:makeBdst
+ }
+
+ }))
+ }catch(error1){
+ console.log("error ", error1)
+
+ }finally{
+
+ }
+ },
+
+ };
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx
new file mode 100644
index 000000000..0a51ebb5d
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx
@@ -0,0 +1,244 @@
+import { getFetch, postFectch, putFectch } from "@/components/lib/api";
+import { upHeadList, type chgBuilding} from "../rainReg";
+
+import { z } from "zod";
+import { makeMdfr, makeRstr } from "../bdstReg";
+import type { TableUpperProps } from "@/app/store/common/type/header";
+
+export const hdtflZod = z.object({
+ bdstInfoPk: z.number().nullish(),
+ ctpvCd: z.number().default(0),
+ sggCd: z.number().default(0),
+ cityText: z.string().nullish(),
+ sggText: z.string().nullish(),
+ daddr: z.string().default(" "),
+ bdstNm: z.string().default(" "),
+ frstArchPrmsnDt: z.date().default(() => new Date()),
+ archChgPrmsnDt: z.date().default(() => new Date()).nullish() ,
+ archArea: z.number().default(0),
+ archChgArea: z.number().nullish().default(0),
+ rgtr:z.string().nullish().default(null),
+ mdfr:z.string().nullish().default(null),
+ reuseBuilding: z
+ .array(
+ z.object({
+ bdstRuseFcltPk: z.number().nullish(),
+ bdstInfoFk: z.number().nullish(),
+ instlCmptnDt: z.coerce.date().default(() => new Date()),
+ instlCst: z.number().nullish().default(0),
+ operMngCd: z.string().nullish().default(""),
+ anlOperCst: z.number().default(0),
+ instlCstSprtYn: z.enum(["Y", "N"]).nullish(),
+ instlCstSprtAmt: z.number().nullish().default(0),
+ grntchBdstCertNo: z.string().nullish().default(""),
+ grntchBdstCertGrd: z.string().nullish().default(""),
+ ruseFcltFlg: z.string().nullish().default(""),
+ bdstUsgCd: z.number().default(0),
+ lawTrgtYn: z.enum(["Y", "N"]).nullish(),
+ rgtr:z.string().nullish().default(null),
+ mdfr:z.string().nullish().default(null),
+ // htdflObj 매핑
+ htdflObj: z
+ .object({
+ htdflFcltPk: z.number().nullish(),
+ bdstRuseFcltFk: z.number().nullish(),
+ etgtType: z.string().default(""),
+ fclCpct: z.number().default(0),
+ plwtYn: z.enum(["Y", "N"]),
+ orgwtWtritSpt: z.number().default(0),
+ orgwtOcrnProcs: z.string().default(""),
+ wtritEntrcTp: z.number().max(4, "온도는 100이상이 될 수 없습니다.")
+ .default(0),
+ amtgnr: z.number().default(0),
+ prcsProcsYn: z.enum(["Y", "N"]),
+ prcsFcltCpct: z.number().default(0),
+ fmYn: z.string().default(""),
+ utztnCpct: z.number().default(0),
+ utztnUsg: z.string().default(""),
+ grssClfg: z.number().default(0),
+ combResdch: z.number().default(0),
+ trbt: z.number().default(0),
+ bod: z.number().default(0),
+ smll: z.number().default(0),
+ crmty: z.number().default(0),
+ tn: z.number().default(0),
+ tph: z.number().default(0),
+ ph: z.number().default(0),
+ clIonQnt: z.number().default(0),
+ cdtnv: z.number().default(0),
+ emsnExitTp: z.number().default(0),
+ rgtr:z.string().nullish().default(null),
+ mdfr:z.string().nullish().default(null),
+ })
+ .default({
+ plwtYn: "N",
+ prcsProcsYn: "N",
+ }),
+ })
+ )
+ .default([]),
+ chgBuilding: z
+ .array(
+ z.object({
+ bdstInfoFk: z.number().nullish(),
+ archChgPrmsnDt: z.coerce.date() ,
+ archChgArea: z.string().default("-").nullish(),
+ bdstChgNm: z.string().default(""),
+ rgtr:z.string().nullish().default(null),
+ mdfr:z.string().nullish().default(null),
+ })
+ )
+ .default([]),
+});
+
+ export type customHtdflBdst = z.infer
+
+
+export type htdflFacState = {
+ htdfl: {
+ isInit: boolean;
+ upHeadList: TableUpperProps[];
+ htdflRes: customHtdflBdst[];
+ };
+};
+type htdflFacSActions = {
+ initHtdfl: (code: string ) => void;
+ htdflBdstUpdate:(data: customHtdflBdst, code:string|number) => void;
+ htdflBdstReg:(data: customHtdflBdst, code:string|number) => void;
+ getHtdflBdstData:(pageNation:number, code:string|number) =>void;
+
+};
+
+const htdflRes: customHtdflBdst[] = [];
+
+export type htdflFacType = htdflFacState & htdflFacSActions;
+
+export const htdflFacStateExport: htdflFacState = {
+ htdfl: {
+ isInit: false,
+ upHeadList: upHeadList,
+ htdflRes: htdflRes,
+ },
+};
+
+
+const initFetch = async (code:string|number) => {
+ const rswtRes = await getFetch(
+ "wr",
+ `/facilityList/1/20/${code}`)
+
+ return rswtRes;
+};
+export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
+ set: any
+) => {
+ return {
+ getHtdflBdstData: async (pageNation: number, code: string | number) => {
+ try {
+ const rswtRes = await getFetch(
+ "wr",
+ `/drain/facilityList/${pageNation}/20/${code}`
+ );
+ console.log(pageNation)
+ // 여기서 상태 업데이트
+ return set((state: htdflFacState) => ({
+ ...state,
+ htdfl: {
+ ...state.htdfl,
+ htdflRes: rswtRes,
+ isInit: false,
+ },
+ }));
+ } catch (e) {
+ console.log(e);
+ }
+ },
+
+
+ initHtdfl: async (code: string ) => {
+ try {
+ const htdflRes = await initFetch(code);
+ set((state: htdflFacState) => {
+ return {
+ ...state,
+ htdfl: {
+ ...state.htdfl,
+ htdflRes: htdflRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ htdflBdstUpdate: async (data: customHtdflBdst, code:string|number) => {
+ try {
+ const chData=await makeMdfr(data)
+ const res = await putFectch("/drain/facility", data);
+ if (res.ok) {
+ alert(" 수정이 완료되었습니다.");
+ }
+
+ const htdflRes = await initFetch(code);
+ set((state: htdflFacState) => ({
+ ...state,
+ htdfl: {
+ ...state.htdfl,
+ htdflRes: htdflRes,
+ isInit: false,
+ },
+ }));
+ } catch (errorUpdate) {
+ alert(
+ "업데이트 오류입니다. " +
+ (errorUpdate instanceof Error ? errorUpdate.message : "")
+ );
+ }
+ },
+ htdflBdstReg: async (data: customHtdflBdst , code:string|number) => {
+ try {
+ const chData=await makeRstr(data)
+ const res = await postFectch("/drain/facility", data);
+ if (res.ok) {
+
+ if(data.chgBuilding.length > 0){
+ await res
+ .json()
+ .then((resData: any) => {
+ const chPK = resData?.data?.bdstInfoPk;
+
+ const makeCh = resData.data.chgBuilding.map(
+ (item: chgBuilding) => ({
+ ...item,
+ bdstInfoFk: chPK,
+ })
+ );
+ const chch = postFectch("/reuseFc/chgBuilding", makeCh);
+ return chch;
+ })
+ .then((chch: any) => {
+ if (chch.ok) {
+ alert("등록이 완료되었습니다.");
+ }
+ });
+ }else{
+ alert("등록이 완료되었습니다.");
+
+ }
+ }
+ const htdflRes = await initFetch(code);
+ set((state: htdflFacState) => ({
+ ...state,
+ htdfl: {
+ ...state.htdfl,
+ htdflRes: htdflRes,
+ isInit: false,
+ },
+ }));
+ } catch (errorReg) {
+ alert("등록 오류입니다.");
+ }
+ },
+ };
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx
new file mode 100644
index 000000000..536114f3f
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx
@@ -0,0 +1,132 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
+
+export const pubFacHeadListExport: TableUpperProps[] = [
+ { id: "sido", title: "시도" },
+ { id: "gugun", title: "시군구" },
+ { id: "bscFctNm", title: "시설명" },
+ { id: "addr", title: "위치" },
+ { id: "efflWqltStndrdNm", title: "지역구분" },
+ { id: "fctCpc", title: "시설용량" },
+ { id: "ruse", title: "재이용여부" },
+ { id: "rswtrYn", title: "등록여부" },
+];
+
+export const pbnstMngUpHeadListExport: TableUpperProps[] = [
+ { id: "choose", title: "선택", type: "checkbox" },
+ { id: "operMthd", title: "운영방식",type: "select", selectData: "ruseMngMtd" },
+ { id: "rprtvBzenty", title: "대행업체", edit: true },
+ {
+ id: "bgngDt",
+ title: "시작일",
+ type: "date",
+ },
+ {
+ id: "endDt",
+ title: "종료일",
+ type: "date",
+ },
+];
+
+export const pplInstlsHeadListExport: TableUpperProps[] = [
+ { id: "choose", title: "선택", type: "checkbox" },
+ { id: "ppMqlt", title: "관재질", type: "select", selectData: "pplQulity" },
+ { id: "pdmt", title: "관경", type: "select", selectData: "pplLenght" },
+ { id: "cpct", title: "연장", edit: true, type: "number" },
+];
+
+export const pbnstDemandHeadListExport: TableUpperProps[] = [
+ { id: "dmdCoNm", title: "수요처명" },
+ { id: "daddr", title: "위치(주소)" },
+ { id: "useUsgCd", title: "사용용도" },
+ { id: "splyBgngDay", title: "공급시작일" },
+ { id: "splyEndDay", title: "공급종료일" },
+ { id: "splyCpct", title: "공급량(m³/일)" },
+ { id: "splyFmYon", title: "공급유량계 유무" },
+];
+
+export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [
+ { id: "ruseUtztnFcltNm", title: "하수처리장명" },
+ { id: "orgwtWtritQnt", title: "원수취수량" },
+ { id: "tmsYn", title: "하수처리량TMS 전후" },
+ { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후" },
+ { id: "dtlPstnExpln", title: "상세위치 설명" },
+];
+export const fcOrgwtsHeadListExport: TableUpperProps[] = [
+ { id: "choose", title: "선택", type: "checkbox" },
+ { id: "sido", title: "시도" },
+ { id: "gugun", title: "시군구" },
+ { id: "bscFctNm", title: "시설명" },
+ { id: "addr", title: "위치" },
+];
+
+
+export const pbnstMngNmExport: chHeadType[] = [
+ { headNm: "upChangeRe", text: "운영대행기간", length: 2 },
+];
+
+export type formDetailType = {
+ id: string;
+ lable: string;
+ type?: string;
+ option?:string
+};
+
+export const wasteWaterFcltINfo: formDetailType[] = [
+ { id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부", type: "selectYn" },
+ { id: "tmsInstlYn", lable: "Tms설치여부", type: "selectYn" },
+ { id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부", type: "selectYn" },
+];
+
+export const concentratedWaterInfo: formDetailType[] = [
+ { id: "erctWtrOcrnCpct", lable: "눙축수 발생량(m³/일)", type: "number" },
+ { id: "erctUswtrLinkSpt", lable: "눙축수연계지점" },
+ { id: "erctUswtrFcltCpct", lable: "시설용량(m³/일)", type: "number" },
+ { id: "erctUswtrPrcsMeth", lable: "눙축수처리방식" },
+ { id: "erctUswtrPrcsMsrcCd", lable: "눙축수처리공법" },
+];
+
+export const ruseFcltinfo: formDetailType[] = [
+ { id: "rprcsFcltCpct", lable: "시설용량(m³/일)", type: "number" },
+ { id: "majorPrcsMsrcCd", lable: "주처리공법" },
+ { id: "addr", lable: "위치(주소)" },
+ { id: "rprcsMthdCd", lable: "재처리방식" },
+ { id: "inoutYn", lable: "위치(처리장 내외)" ,type: "selectYn" }, // 머가 내? 외?,
+ { id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" },
+];
+
+export const businessMoneyInfo: formDetailType[] = [
+ { id: "gvsbs", lable: "국고", type: "number" },
+ { id: "lcep", lable: "지방비", type: "number" },
+ { id: "cusrAlotm", lable: "민간투자비", type: "number" },
+ { id: "etc", lable: "기타" },
+ { id: "totalMoney", lable: "합계", type: "number" ,option:"readOnly" },
+];
+
+export const businessSttnInfo: formDetailType[] = [
+ { id: "seCd", lable: "구분" },
+ { id: "bizMthdCd", lable: "사업방식" },
+ { id: "bizCmcnDay", lable: "사업준공일", type: "date" },
+ { id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" },
+];
+
+export const ruseFcltIntakeList: formDetailType[] = [
+ { id: "seCd", lable: "구분" },
+ { id: "bizMthdCd", lable: "사업방식" },
+ { id: "bizCmcnDay", lable: "사업준공일", type: "date" },
+ { id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" },
+];
+
+export const ruseWaterQulityList: formDetailType[] = [
+ { id: "bod", lable: "BOD(mg/L)", type: "number" },
+ { id: "grssClfg", lable: "총대장균군수(개/mg)", type: "number" },
+ { id: "combResdch", lable: "결합잔류염소(mh/L)", type: "number" },
+ { id: "trbt", lable: "탁도(NTU)", type: "number" },
+ { id: "smll", lable: "냄새", type: "number" },
+ { id: "crmty", lable: "색도", type: "number" },
+ { id: "tn", lable: "총질소(mg/L)", type: "number" },
+ { id: "tph", lable: "총인(mg/L)", type: "number" },
+ { id: "ph", lable: "수소이온농도", type: "number" },
+ { id: "clIonQnt", lable: "염화물(mg/L)", type: "number" },
+ { id: "cdtnv", lable: "전기전도도(μs/cm)", type: "number" },
+];
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx
new file mode 100644
index 000000000..fb799c26c
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx
@@ -0,0 +1,404 @@
+import { TEST_UUID } from "../rainReg";
+import {
+ deleteFectch,
+ fetchType,
+ getFetch,
+ postFectch,
+ putFectch,
+} from "@/components/lib/api";
+import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
+import {
+ type customPbnst,
+ type fcBizType,
+ type pbnstInsertIndex,
+ type pubHasuType,
+} from "./type";
+import type { SelectDataType } from "@common/business_components/ui";
+import {
+ pbnstMngUpHeadListExport,
+ pbnstOrgwtHeadListRxport,
+ pbnstMngNmExport,
+ pubFacHeadListExport,
+ pplInstlsHeadListExport,
+ pbnstDemandHeadListExport,
+ fcOrgwtsHeadListExport,
+} from "./headList";
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import toast from "react-hot-toast";
+
+const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }];
+const pubFacHeadList = pubFacHeadListExport;
+const pbnstMngUpHeadList = pbnstMngUpHeadListExport;
+const pbnstOrgwtHeadList = pbnstOrgwtHeadListRxport;
+const pbnstMngNm = pbnstMngNmExport;
+const pplInstlsHeadLisat = pplInstlsHeadListExport;
+const pbnstDemandHeadList = pbnstDemandHeadListExport;
+const fcOrgwtsHeadList = fcOrgwtsHeadListExport;
+
+export type pubFacState = {
+ pbnst: {
+ isInit: boolean;
+ pubFacHeadList: TableUpperProps[];
+ pbnstMngUpHeadList: TableUpperProps[];
+ pbnstMngNm: chHeadType[];
+ pbnstHasuRes: pubHasuType[];
+ pbnstRes: customPbnst[] | null; // 배열에서 단일 객체 또는 null로 변경
+ pbnstResObj: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경
+ pbnstBizCycle: SelectDataType[];
+ selectLabel: SelectDataType[];
+ pbnstOrgwtHeadList: TableUpperProps[];
+ pplInstlsHeadLisat: TableUpperProps[];
+ pbnstDemandHeadList: TableUpperProps[];
+ fcOrgwtsHeadList: TableUpperProps[];
+ pbnstMngRegData: customPbnst[];
+ pbnsUpdateIndex: pbnstInsertIndex;
+ dmdComList: any[];
+ };
+};
+type pubFacActions = {
+ pubHasuInit: (page: string, sggOrCity: string) => void;
+ pbnstRegClick: (pubHasuRes: pubHasuType) => void;
+ pbnstReg: (txt: string | undefined) => void;
+ pbnstInsert(pbnstRes: customPbnst): Promise;
+ appendRuseFclt(array: customPbnst[]): void;
+ fileDelete: (atflCd: string) => void;
+ fileDownLoad: (atflCd: string) => void;
+ //pbnstMngData: (data: customPbnst[]) => void;
+ //pbnstBizData(data: fcBizType): void;
+ // getBizCycle: (pbnstObj: customPbnst) => void;
+ getpbnstInsertIndex: (data: pbnstInsertIndex) => void;
+ pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void;
+ pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void;
+ pubHasuSearch :(page: string, sggOrCity: string , searchTxt:string) => void
+};
+export type pubFacType = pubFacState & pubFacActions;
+
+export const pubFacStateExport: pubFacState = {
+ pbnst: {
+ isInit: false,
+ pubFacHeadList: pubFacHeadList,
+ pbnstMngUpHeadList: pbnstMngUpHeadList,
+ pbnstMngNm: pbnstMngNm,
+ pbnstOrgwtHeadList: pbnstOrgwtHeadList,
+ pplInstlsHeadLisat: pplInstlsHeadLisat,
+ pbnstDemandHeadList: pbnstDemandHeadList,
+ fcOrgwtsHeadList: fcOrgwtsHeadList,
+ selectLabel: selectLabel,
+ pbnstResObj: null, // 초기값을 null로 변경
+ pbnstHasuRes: [],
+ pbnstRes: [], // 초기값을 null로 변경
+ pbnstBizCycle: [{ text: "없음", val: "1" }],
+ pbnstMngRegData: [],
+ pbnsUpdateIndex: {} as pbnstInsertIndex,
+ dmdComList: [],
+ },
+};
+
+const checkWrRegList = async () => {
+ const wrRegList = await getFetch("wr", `/reuseFc/pubFc`);
+ return wrRegList;
+};
+
+const hasuListFetch = async (page: string, sggOrCity: string, searchTxt?:string) => {
+ const checkWrRegListRes = await checkWrRegList();
+
+ console.log(' checkWrRegListRes ', checkWrRegListRes)
+let url = `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity? sggOrCity : "11"}/0/1/SW`;
+
+
+const data = checkWrRegListRes.filter((item:string) => item !== "")
+ console.log(' checkWrRegListRes ' )
+if(searchTxt){
+ url= url +`/${searchTxt}`
+
+}
+ const rainRes = await postFectch(
+ url,
+ data,
+ fetchType.COMMON
+ );
+
+ const hasuList = rainRes.data.map((item: any) => {
+ return {
+ ...item,
+ ruse: item.ruse === false ? "N" : "Y",
+ };
+ });
+
+ return hasuList;
+};
+
+const initFetch = async (ruseFcltPk: string | undefined) => {
+ const pbnstRes = await getFetch("wr", `/reuseFc/pubFc/${ruseFcltPk}`);
+ return pbnstRes;
+};
+
+export const writeRgtrAndMdfr = (data: customPbnst[]) => {
+
+ data.forEach((pbnst) => {
+ pbnst.rgtr = TEST_UUID;
+ pbnst.mdfr = TEST_UUID;
+
+ pbnst.fcBizs = pbnst.fcBizs?.map((item) => {
+ item.rgtr = TEST_UUID;
+ item.mdfr = TEST_UUID;
+ item.fcOrgwts = item.fcOrgwts?.map((orgwt) => {
+ orgwt.mdfr = TEST_UUID;
+ orgwt.rgtr = TEST_UUID;
+ return orgwt;
+ });
+
+ item.fcDemands = item.fcDemands?.map((dmd) => {
+ dmd.mdfr = TEST_UUID;
+ dmd.rgtr = TEST_UUID;
+ return dmd;
+ });
+ return item;
+ });
+ pbnst.fcOpers = pbnst?.fcOpers?.map((oper) => {
+ oper.rgtr = TEST_UUID;
+ oper.mdfr = TEST_UUID;
+ return oper;
+ });
+ pbnst.fcFiles = pbnst.fcFiles?.map((file) => {
+ file.rgtr = TEST_UUID;
+ file.mdfr = TEST_UUID;
+ return file;
+ });
+});
+
+
+
+ return data;
+};
+export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
+ return {
+ pubHasuInit: async (page: string, sggOrCity: string) => {
+ try {
+ const pbnstHasuRes = await hasuListFetch(page, sggOrCity);
+
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstHasuRes: pbnstHasuRes,
+ isInit: false,
+ },
+ }));
+ } catch (errorHasu) {
+ console.log(errorHasu);
+ }
+ },pubHasuSearch : async(page: string, sggOrCity: string , searchTxt:string)=> {
+
+ try{
+ const pbnstHasuRes = await hasuListFetch(page, sggOrCity,searchTxt);
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstHasuRes: pbnstHasuRes,
+ isInit: false,
+ },
+ }));
+ } catch (errorHasu) {
+ console.log(errorHasu);
+ }
+ },
+ pbnstRegClick: async (pubHasuRes: pubHasuType) => {
+ try {
+ const pbnstRes = await initFetch(pubHasuRes.bscFctCd);
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstRes: pbnstRes,
+ isInit: false,
+ },
+ }));
+ } catch (errorHasu) {
+ console.log(errorHasu);
+ }
+ },
+
+ pbnstReg: async (txt: string | undefined) => {
+ try {
+ const pbnstRes = await hasuListFetch("11", "11");
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstRes: pbnstRes,
+ isInit: false,
+ },
+ }));
+ } catch (errorHasu) {
+ console.log(errorHasu);
+ }
+ },
+ pbnstInsert: async (pbnstRes: customPbnst) => {
+ try {
+
+ const response = await postFectch(
+ `/reuseFc/pubFc`,
+ pbnstRes
+ );
+ if( response.status === 200) {
+ toast.success(`${pbnstRes.ruseUtztnFcltNm} 하수재이용 시설이 등록되었습니다.`);
+ }
+ const pbnstHasuRes = await hasuListFetch('1', '0');
+
+
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstRes: pbnstHasuRes,
+ isInit: false,
+ },
+ }));
+ } catch (error) {
+ console.error("Error updating pbnst:", error);
+ }
+ },pbnstRuseFcltUpdate : async(ruseRes:customPbnst[])=>{
+ try {
+
+ const response = await putFectch(
+ `/reuseFc/pubFc`,
+ ruseRes
+ );
+
+ } catch (error) {
+ console.error("Error pbnstRuseFcltUpdate:", error);
+ }
+ } ,pbnstRuseBizUpdate : async(ruseRes:fcBizType[])=>{
+ try {
+
+ console.log('ruseRes ', ruseRes)
+ const response = await putFectch(
+ `/reuseFc/pubFcBiz`,
+ ruseRes
+ );
+ const pbnstRes = await hasuListFetch("11", "11");
+
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstRes: pbnstRes,
+ isInit: false,
+ },
+ }));
+ } catch (error) {
+ console.error("Error pbnstRuseFcltUpdate:", error);
+ }
+ } ,
+ getBizCycle: async (pbnstObj: customPbnst) => {
+ const pbnstBizCycle = pbnstObj.fcBizs.map((item) => {
+ return {
+ text: `${item.cycl}차`,
+ val: item.cycl,
+ };
+ });
+
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstBizCycle: pbnstBizCycle,
+ pbnstResObj: pbnstObj,
+ isInit: false,
+ },
+ }));
+ },
+ fileDelete: async (atflCd: string) => {
+ try {
+ const response = await deleteFectch(
+ `/attach-service/api/v1/atfl/attachments/atflCd//${atflCd}`,
+ undefined,
+ fetchType.CS
+ );
+
+ console.log("File deleted successfully:", response);
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ isInit: false,
+ },
+ }));
+ } catch (error) {
+ console.error("Error deleting file:", error);
+ }
+ },
+ fileDownLoad: async (atflCd: string) => {
+ try {
+ const response = await getFetch(
+ fetchType.CS,
+ `/attach-service/api/v1/atflcd/download/${atflCd}`
+ );
+
+ if (!response.ok) {
+ throw new Error(`Error downloading file: ${response.statusText}`);
+ }
+ } catch (error) {
+ console.error("Error downloading file:", error);
+ }
+ },
+
+ // pbnstMngData: (data: customPbnst[]) => {
+ // if (data.length > 0) {
+ // }
+ // return set((state: pubFacState) => {
+ // state.pbnst.pbnstMngRegData = data;
+ // state.pbnst.pbnstBizCycle =
+ // data.length <= 0
+ // ? [{ text: "없음", val: "1" }]
+ // : state.pbnst.pbnstBizCycle;
+ // return state;
+ // });
+ // },
+
+ // pbnstBizData: (data: fcBizType) => {
+ // return set((state: pubFacState) => {
+ // if (state.pbnst.pbnstMngRegData) {
+ // const regData = state.pbnst.pbnstMngRegData.find(
+ // (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk
+ // );
+ // if (regData) {
+ // const bizIdx = regData.fcBizs.findIndex(
+ // (item) => item.pbnstRuseFcltBizPk == data.pbnstRuseFcltBizPk
+ // );
+
+ // if (bizIdx >= 0) {
+ // regData.fcBizs[bizIdx] = data;
+ // const pbnstData = state.pbnst.pbnstMngRegData
+ // state.pbnst.pbnstMngRegData= [...pbnstData]
+
+ // }
+ // }
+ // }
+ // return state;
+ // });
+ // },
+ getpbnstInsertIndex: async (data: pbnstInsertIndex) => {
+ return set((state: pubFacState) => {
+ state.pbnst.pbnsUpdateIndex = data;
+ return state;
+ });
+ },
+ appendRuseFclt: async (array: customPbnst[]) => {
+ try {
+ return set((state: pubFacState) => ({
+ ...state,
+ pbnst: {
+ ...state.pbnst,
+ pbnstRes: array,
+ isInit: false,
+ },
+ }));
+ } catch (e) {
+ console.log(e);
+ }
+ }
+ };
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx
new file mode 100644
index 000000000..a34985810
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx
@@ -0,0 +1,244 @@
+import { z } from "zod";
+import { TEST_UUID } from "../rainReg";
+
+export type customPbnst = z.infer;
+
+export const pbnstReg = [] as customPbnst[];
+export type TableProps = {
+ id: string;
+ title: string;
+};
+
+export type selectLabel = {
+ text: string;
+ val: string;
+};
+
+export type pbnstInsertIndex ={
+ mng:number,
+ biz:number
+}
+
+export type publicReuseFacilityType = {
+ sido: string;
+ sigungo: string;
+ facilityName: string;
+ location: string;
+ locationgubun: string;
+ facilityCapacity: string;
+ yn?: string;
+ authoDay?: string;
+ area?: string;
+ reuse?: string;
+ register?: string;
+ swtrmtFcltFk: string;
+};
+
+export type ruseFcltType = {
+ swtrmtFcltFk: string;
+ pbnstRuseFcltPk: string;
+ fcltNm: string;
+ fcltCpct: number;
+ swtrmtCpct: number;
+ ruseCpct: number;
+ splyExtraCpct: number;
+};
+
+export type PbnstDemandComType = {
+ dmdInfoPk : string | '';
+ bzmnNo : string | '';
+ dmdCoNm : string | '';
+ daddr : string | '';
+ telno : string | '';
+ rgtr : string | '';
+ useUsgCd : string | '';
+ ctpvCd : string | '';
+ sggCd : string | '';
+ dmdAplyPswd: string | '';
+ splyCpct: number | 0;
+ splyFmYn:string|'Y'
+// dmdInfoFk:string|''
+}
+
+const pubHasuZod = z.object({
+ choose: z.boolean().default(false),
+ bscFctCd: z.string(),
+ sido: z.string().default(""),
+ gugun: z.string().default(""),
+ bscFctNm: z.string().default(""),
+ efflWqltStndrdNm: z.string().default(""),
+ fctCpc: z.number().default(0),
+ addr:z.string().nullish()
+});
+
+
+export type pubHasuType = z.infer;
+const zDate = z.preprocess((v) => (v ? new Date(v as string) : undefined), z.date()).nullish() ;
+const zDateNullish = zDate.nullish();
+const zDateDefaultNow = zDate.default(new Date());
+
+const zNum = z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number());
+const zNumNullish = zNum.nullish();
+const zNumDefaultZero = zNum.default(0).nullish();
+
+const pplInstlSchema = z.object({
+ ruseFcltBizFk: zNumNullish,
+ choose: z.boolean().default(false),
+ pdmt: z.string().default(''),
+ ppMqlt: z.string().default(""),
+ cpct: zNumDefaultZero,
+});
+
+const fcFileSchema = z.object({
+ ruseFcltFk: z.string().nullish(),
+ fileTkn: z.string(),
+ filePath: z.string(),
+ fileKnd: z.string(),
+ regDt: zDateDefaultNow.nullish(),
+ rgtr: z.string().nullish(),
+ mdfcnDt: zDateDefaultNow.nullish(),
+ mdfr: z.string().nullish(),
+});
+
+export const fcOperSchema = z.object({
+ pbnstRuseFcltOperInfoPk: zNumNullish,
+ pbnstRuseFcltFk: z.string().nullish(),
+ operMthd: z.string(),
+ rprtvBzenty: z.string(),
+ bgngDt: zDateDefaultNow,
+ endDt: zDateDefaultNow,
+ regDt: zDateNullish,
+ rgtr: z.string().default(""),
+ mdfcnDt: zDateNullish,
+ mdfr: z.string().default(""),
+ choose: z.boolean().default(false),
+});
+
+const fcOrgwtSchema = z.object({
+ pbnstRuseFcltBizFk:zNumNullish,
+ swtrmtFcltFk: z.string().nullish(),
+ orgwtWtritQnt: zNum,
+ tmsYn: z.enum(["Y", "N"]).default("N"),
+ dschgFmYn: z.enum(["Y", "N"]).default("N"),
+ dtlPstnExpln: z.string().default(''),
+ regDt: zDateNullish,
+ rgtr: z.string().default(''),
+ mdfcnDt: zDateNullish,
+ mdfr: z.string().default(''),
+ choose: z.boolean().default(false),
+});
+
+const dmdColist = z.object({
+ dmdInfoPk: z.string().default(''),
+ dmdCoNm: z.string().default(''),
+ daddr: z.string(),
+ useUsgCd: z.string().nullish(),
+ splyBgngDay: zDateDefaultNow,
+ splyEndDay: zDateDefaultNow,
+ splyCpct: zNumDefaultZero,
+ splyFmYn: z.string().nullish(),
+ rgtr: z.string().nullish(),
+ mdfr: z.string().nullish(),
+ pbnstRuseFcltBizPk: zNumDefaultZero,
+ pbnstRuseFcltFk: z.string().nullish(),
+});
+
+export const fcBizSchema = z.object({
+ pbnstRuseFcltBizPk: zNumNullish,
+ pbnstRuseFcltFk: z.string().nullish(),
+ superkey: z.string().default("").nullish(),
+ cycl: zNum.default(1),
+ seCd: z.string().default(""),
+ bizMthdCd: z.string().default(""),
+ instlAprvSncnDt: zDateDefaultNow,
+ bizCmcnDay: zDateDefaultNow,
+ gvsbs: zNumDefaultZero,
+ lcep: zNumDefaultZero,
+ cusrAlotm: zNumDefaultZero,
+ etc: z.string().default(''),
+ totalMoney: zNumNullish.default(0),
+ rprcsFcltCpct: zNumDefaultZero,
+ majorPrcsMsrcCd: z.string().default(""),
+ addr: z.string().default(''),
+ rprcsMthdCd: z.string().default(""),
+ inoutYn: z.enum(["Y", "N"]).default("Y"),
+ mainSplyPumpCpct: zNumNullish,
+ erctWtrOcrnCpct: zNumNullish,
+ erctUswtrLinkSpt: z.string().nullish(),
+ erctUswtrFcltCpct: zNumNullish,
+ erctUswtrPrcsMeth: z.string().nullish(),
+ erctUswtrPrcsMsrcCd: z.string().nullish(),
+ wwtEmsnFcltPrmsnYn: z.string().default("Y"),
+ tmsInstlYn: z.string().default("Y"),
+ pbnstDrngInflwExclYn: z.string().default("Y"),
+ bod: zNumDefaultZero,
+ grssClfg: zNumDefaultZero,
+ combResdch: zNumDefaultZero,
+ trbt: zNumDefaultZero,
+ clIonQnt: zNumDefaultZero,
+ smll: zNumDefaultZero,
+ crmty: zNumDefaultZero,
+ tph: zNumDefaultZero,
+ tn: zNumDefaultZero,
+ ph: zNumDefaultZero,
+ cdtnv: zNumDefaultZero,
+ designCst: zNumNullish,
+ cstrnSpvsCst: zNumNullish,
+ fcltSbsdCst: zNumNullish,
+ wstCst: zNumNullish,
+ cnstCmcnCst: zNumNullish,
+ mntrgEqpmntInstlCst: zNumNullish,
+ gisDbCst: zNumNullish,
+ elpwrMtrngCst: zNumNullish,
+ mchnCst: zNumNullish,
+ archCst: zNumNullish,
+ pplCst: zNumNullish,
+ ruseFcltCst: zNumNullish,
+ designCstClcln: zNumNullish,
+ cstrnSpvsCstClcln: zNumNullish,
+ fcltSbsdCstClcln: zNumNullish,
+ wstCstClcln: zNumNullish,
+ cnstCmcnCstClcln: zNumNullish,
+ mntrgEqpmntInstlCstClcln: zNumDefaultZero,
+ gisDbCstClcln: zNumNullish,
+ elpwrMtrngCstClcln: zNumNullish,
+ mchnCstClcln: zNumNullish,
+ archCstClcln: zNumNullish,
+ pplCstClcln: zNumNullish,
+ ruseFcltCstClcln: zNumNullish,
+ fcOrgwts: z.array(fcOrgwtSchema).nullish(),
+ pplInstls: z.array(pplInstlSchema).nullish(),
+ fcDemands: z.array(dmdColist).nullish(),
+ flg: z.string().nullish(),
+ regDt: z.string().nullish(),
+ rgtr: z.string().nullish(),
+ mdfcnDt: z.string().nullish(),
+ mdfr: z.string().nullish(),
+});
+
+export const pbnstRegZod = z.object({
+ pbnstRuseFcltPk: z.string().default(''),
+ swtrmtFcltFk: z.string().default(""),
+ ruseUtztnFcltNm: z.string().default(""),
+ fcltCpct: zNumDefaultZero,
+ ruseCpct: zNumDefaultZero,
+ splyExtraCpct: zNumDefaultZero,
+ regDt: zDateDefaultNow,
+ rgtr: z.string().default("test"),
+ mdfcnDt: zDateDefaultNow,
+ mdfr: z.string().default("test"),
+ fcFiles: z.array(fcFileSchema).default([]).nullish(),
+ fcBizs: z.array(fcBizSchema).default([]),
+ fcOpers: z.array(fcOperSchema).default([]).nullish(),
+});
+
+export const pbnstRegArrayZod = z.array(pbnstRegZod)
+
+export type PbnstRegArrrayType = z.infer
+
+export type fcBizType = z.infer;
+export type fcOrgwtType = z.infer;
+export type ppInstlType = z.infer;
+export type operType = z.infer;
+export type fcFileType = z.infer;
+
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx
new file mode 100644
index 000000000..5b3ad6813
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx
@@ -0,0 +1,272 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import { getFetch, postFectch, putFectch } from "@/components/lib/api";
+import { z } from "zod";
+import { makeMdfr, makeRstr } from "../bdstReg";
+
+const validationMessages = {
+ required: (field: string) => `${field}을(를) 입력해주세요.`,
+ requiredSelect: (field: string) => `${field}을(를) 선택해주세요.`,
+ yearFormat: '4자리 연도만 입력하세요',
+};
+
+export const TEST_UUID= '2d4b151d-1828-41e0-91d9-4cd28ea1cc7e'
+
+const rainyObjSchema = z.object({
+ bdstReuseFcltFk: z.number().nullish(),
+ pntfColKnd: z.string().default(""),
+ pntfColArea: z.number().default(0),
+ dtfcltCpct: z.number().default(0),
+ filtrTrtmfctYn: z.string().default("Y").nullish(),
+ filtrTrtmfctCpct: z.number().nullish().default(0),
+ filtrTrtmfctPrs: z.string().default(""),
+ annRnwtQty: z.number().default(0),
+ oilqMeasMthd: z.string().default("").nullish(),
+ rgtr:z.string().nullish(),
+ mdfr:z.string().nullish(),
+}).refine((data) => data.pntfColKnd.length > 0, {
+ message: validationMessages.requiredSelect("종류"),
+ path: ["pntfColKnd"],
+}).refine((data) => data.pntfColArea > 0, {
+ message: validationMessages.required("면적(m³)"),
+ path: ["pntfColArea"],
+});
+
+const reuseBuildingSchema = z.object({
+ bdstRuseFcltPk: z.number().nullish(),
+ bdstInfoFk:z.number().nullish(),
+ instlCmptnDt: z.coerce.date().default(() => new Date()),
+ instlCst: z.number().nullish(),
+ operMngCd: z.string().optional().default(""),
+ anlOperCst: z.number().default(0),
+ instlCstSprtYn: z.string().default("Y"),
+ instlCstSprtAmt: z.number().nullish(),
+ grntchBdstCertYn: z.string().default("Y"),
+ grntchBdstCertYr: z.string().default("")
+ .refine((year)=> year.length===0 || /^\d{4}$/.test(year),{
+ message: validationMessages.yearFormat
+ }),
+ grntchBdstCertNo: z.string().default(""),
+ grntchBdstCertGrd: z.string().default(""),
+ crgRdctYn: z.string().default("N").nullish(), /// 안쓰는 값
+ crgRdctBss: z.string().default("").nullish(), /// 안쓰는 값
+ crgRdctAmt: z.number().default(0), // 안쓰는 값
+ ruseFcltFlg: z.string().default(""),
+ bdstUsgCd: z.number().default(0),
+ lawTrgtYn: z.string().default("Y"),
+ rgtr:z.string().nullish(),
+ mdfr:z.string().nullish(),
+ rainyObj: rainyObjSchema.default({})
+}).refine((data) => data.bdstUsgCd > 0, {
+ message: validationMessages.requiredSelect("건축물용도"),
+ path: ["bdstUsgCd"],
+});
+
+const chgBuildingSchema = z.object({
+ bdstInfoFk: z.number().nullish(),
+ archChgPrmsnDt: z.coerce.date({required_error: validationMessages.required("허가일")}),
+ archChgArea: z.string().default("-"),
+ bdstChgNm: z.string().default(""),
+ rgtr:z.string().nullish(),
+ mdfr:z.string().nullish(),
+}).refine(data => data.bdstChgNm.length > 0, {
+ message: validationMessages.requiredSelect("구분"),
+ path: ["bdstChgNm"]
+});
+
+export const rainZod = z.object({
+ bdstInfoPk: z.number().optional(),
+ ctpvCd: z.number().default(0),
+ sggCd: z.number().default(0),
+ daddr: z.string().default(""),
+ bdstNm: z.string().default(""),
+ frstArchPrmsnDt: z.date().default(() => new Date()),
+ archChgPrmsnDt: z.coerce.date().nullish().default(null),
+ archArea: z.number().default(0),
+ archChgArea: z.number().default(0),
+ rgtr:z.string().nullish(),
+ mdfr:z.string().nullish(),
+ reuseBuilding: z.array(reuseBuildingSchema).default([]),
+ chgBuilding: z.array(chgBuildingSchema).default([])
+})
+
+export type chgBuilding={
+ bdstInfoFk?: number|null,
+ archChgPrmsnDt?: Date,
+ archChgArea?: string,
+ bdstChgNm?: string
+ rgtr?:string|null;
+ mdfr?:string|null;
+}
+export type customRainBdst = z.infer
+
+export const upHeadList: TableUpperProps[] = [
+ { id: "cityText", title: "시도" },
+ { id: "sggText", title: "시군구" },
+ { id: "bdstNm", title: "시설명" },
+ { id: "daddr", title: "위치" },
+ { id: "bdsgUsgText", title: "건축물용도" },
+ { id: "frstArchPrmsnDt", title: "최초건축허가일" },
+ { id: "archArea", title: "건축면적" },
+ { id: "lawTrgtYn", title: "법적의무대상여부" },
+ { id: "bdstChgYn", title: "건축물변경여부" },
+];
+
+const rainRes: customRainBdst[] = [];
+
+
+export const selectClass = "w-full h-full !text-xl";
+
+export type rainFacState = {
+ rain: {
+ isInit: boolean;
+ upHeadList: TableUpperProps[];
+ rainRes: customRainBdst[];
+ };
+};
+type rainFacSActions = {
+ initRain: (code:string|number) => void;
+ getRainData:(pageNation:number, code:string|number) =>void;
+ rainSearch: (txt:string,pageNation:number,code:string|number) => void;
+ rainBdstReg: (data: customRainBdst, code:string|number) => void;
+ rainBdstUpdate: (data: customRainBdst, code:string|number) => void;
+};
+
+export type rainFacType = rainFacState & rainFacSActions;
+
+export const rainFacStateExport: rainFacState = {
+ rain: {
+ isInit: false,
+ rainRes: rainRes,
+ upHeadList: upHeadList,
+ },
+};
+
+const initFetch = async (code:string|number) => {
+ const rainRes =await getFetch("wr", `/reuseFc/rainyInfoList/1/10/${code}`);
+ return rainRes;
+};
+export const rainFacActionsExport: (set: any) => rainFacSActions = (
+ set: any
+) => {
+ return {
+ getRainData: async(pageNation:number, code:string|number) =>{
+ try{
+ const rainRes =await getFetch("wr", `/reuseFc/rainyInfoList/${pageNation}/10/${code}`);
+
+
+ // 여기서 상태 업데이트
+ return set((state: rainFacState) => ({
+ ...state,
+ rain: {
+ ...state.rain,
+ rainRes: rainRes,
+ isInit: false,
+ },
+ }));
+
+ }catch(e){
+ console.log(e)
+
+ }
+ },
+
+ initRain: async (code:string|number) => {
+ try {
+ // 파라이터 수정 통합관리자 =0, 시관리자=시코드, 시군구 관리자= 시군구 코드 를 세번째 파라미터로 지정 / 건축물 서치가 있을경우 4번째 파라미터로 던지기 즉 1/20/42(서울시)/영현빌딩 이런식으로)
+ const rainRes = await initFetch(code);
+ // 여기서 상태 업데이트
+ return set((state: rainFacState) => ({
+ ...state,
+ rain: {
+ ...state.rain,
+ rainRes: rainRes,
+ isInit: false,
+ },
+ }));
+ } catch (error) {
+ console.log("error", error);
+ }
+ },
+ rainSearch: async(txt:string,pageNation:number) =>{
+ try{
+
+ const rainRes = await getFetch('wr' , `/reuseFc/rainyInfoList/${pageNation}/20/41` +(txt? `/${txt}`:''))
+ set((state: rainFacState) => {
+ return {
+ rain: {
+ ...state.rain,
+ rainRes: rainRes,
+ isInit: false,
+ },
+ };
+ })}
+ catch(erTxt){
+ console.log("error", erTxt)
+ }
+ },
+ rainBdstReg: async (data: customRainBdst,code:string|number) => {
+ try {
+
+ const test =await makeRstr(data);
+ const res = await postFectch("/reuseFc/rainyInfo", test);
+ if(res.ok){
+ if(data.chgBuilding.length > 0){
+ await res.json().then((resData: any) => {
+ const chPK = resData?.data?.bdstInfoPk
+ const makeCh= resData.data.chgBuilding.map((item: chgBuilding) =>
+ ( {
+ ...item,
+ bdstInfoFk: chPK,
+ })
+ );
+ const chch= postFectch("/reuseFc/chgBuilding", makeCh);
+ return chch;
+ }).then((chch: any) => {
+ if(chch.ok) {
+ alert("등록이 완료되었습니다.");
+ }
+ })
+ }else{
+ alert("등록이 완료되었습니다.");
+ }
+ }
+ const rainRes = await initFetch(code);
+ set((state: rainFacState) => ({
+ ...state,
+ rain: {
+ ...state.rain,
+ rainRes: rainRes,
+ isInit: false,
+ },
+ }));
+ } catch (e) {
+ console.log("e", e);
+ alert("등록 오류입니다.");
+ } finally {
+ }
+ },
+ rainBdstUpdate: async (data: customRainBdst,code:string|number) => {
+ try {
+ const chData =await makeMdfr(data);
+ const res = await putFectch("/reuseFc/rainyInfo", chData);
+ console.log('rainUpdate', res);
+ if(res.ok){
+ alert(" 수정이 완료되었습니다.")
+ }
+ const rainRes = await initFetch(code);
+ set((state: rainFacState) => ({
+ ...state,
+ rain: {
+ ...state.rain,
+ rainRes: rainRes,
+ isInit: false,
+ },
+ }));
+ } catch (e) {
+ console.log("e", e);
+ alert("업데이트 오류입니다.");
+ } finally {
+ }
+ }
+ }}
+
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx
new file mode 100644
index 000000000..3c2504b9a
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx
@@ -0,0 +1,262 @@
+import { getFetch, postFectch, putFectch } from "@/components/lib/api";
+import { upHeadList, type chgBuilding } from "../rainReg";
+
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import { z } from "zod";
+import { makeMdfr, makeRstr } from "../bdstReg";
+
+export const rswtZod = z.object({
+ bdstInfoPk: z.number().nullish(),
+ ctpvCd: z.number().default(0),
+ sggCd: z.number().default(0),
+ daddr: z.string().default(""),
+ bdstNm: z.string().default(""),
+ frstArchPrmsnDt: z.date().default(() => new Date()),
+ archChgPrmsnDt: z.coerce.date().nullish().default(null),
+ chBuildingYn: z.string().nullish(),
+ archArea: z.number().default(0),
+ archChgArea: z.number().default(0),
+ rgtr: z.string().nullish().default(null),
+ mdfr: z.string().nullish().default(null),
+ bdstUsgText: z.string().default(""),
+ cityText: z.string().default(""),
+ sggText: z.string().default(""),
+
+ reuseBuilding: z
+ .array(
+ z.object({
+ bdstRuseFcltPk: z.number().nullish(),
+ bdstInfoFk: z.number().nullish(),
+ instlCmptnDt: z.coerce.date().default(() => new Date()),
+ instlCst: z.number().default(0),
+ operMngCd: z.string().nullish().default(""),
+
+ anlOperCst: z.number().default(0),
+ instlCstSprtYn: z.enum(["Y", "N"]),
+ instlCstSprtAmt: z.number().default(0),
+
+ grntchBdstCertYn: z.enum(["Y", "N"]),
+ grntchBdstCertYr: z
+ .string()
+ .default("")
+ .refine((year) => year.length === 0 || /^\d{4}$/.test(year), {
+ message: "4자리 연도만 입력하세요",
+ }),
+ grntchBdstCertNo: z.string().default(""),
+ grntchBdstCertGrd: z.string().default(""),
+
+ crgRdctYn: z.string().default("N").nullish(), // 안쓰는 값
+ crgRdctBss: z.string().default("").nullish(), /// 안쓰는 값
+ crgRdctAmt: z.number().default(0), // 안쓰는 값
+ ruseFcltFlg: z.string().default(""),
+ bdstUsgCd: z.number().default(0),
+ lawTrgtYn: z.string().default(""),
+ rgtr: z.string().nullish().default(null),
+ mdfr: z.string().nullish().default(null),
+
+ rswtrObj: z
+ .object({
+ bdstRuseFcltFk: z.number().nullish(),
+ wtrUsqty: z.number().default(0),
+ oblgTrgtWtrUsqty: z.number().nullish().default(0),
+ orgwtKndCd: z.string().default(""),
+ filtrTrtmfctCpct: z.number().default(0),
+ filtrTrtmfctProcs: z.string().default(""),
+ filtrTrtmfctUsgCd: z.string().default("").nullish(),
+ rswtrUsqty: z.number().default(0),
+ altUswtrUtztnYn: z.enum(["Y", "N"]).nullish(), //안쓰는값
+ altUswtrKndCd: z.string().default("").nullish(), //안쓰는값
+ altUswtrUtztnQnt: z.number().default(0), //안쓰는값
+ altUswtrIdntyMthdCd: z.string().default("").nullish(), //안쓰는값
+ rgtr: z.string().nullish().default(null),
+ mdfr: z.string().nullish().default(null),
+ })
+ .default({}),
+ })
+ )
+ .default([]),
+
+ chgBuilding: z
+ .array(
+ z.object({
+ bdstInfoFk: z.number().nullish(),
+ archChgPrmsnDt: z.coerce.date(),
+ archChgArea: z.string().default("-"),
+ bdstChgNm: z.string().default(""),
+ rgtr: z.string().nullish().default(null),
+ mdfr: z.string().nullish().default(null),
+ })
+ )
+ .default([]),
+});
+
+export type customRswtBdst = z.infer;
+
+const rswtRes: customRswtBdst[] = [];
+
+export type rswtFacState = {
+ rswt: {
+ isInit: boolean;
+ upHeadList: TableUpperProps[];
+ rswtRes: customRswtBdst[];
+ };
+};
+type rswtFacSActions = {
+ initRswt: (code: string | number) => void;
+ rswtBdstUpdate: (data: customRswtBdst, code: string | number) => void;
+ getRswtBdstData: (pageNation: number, code: string | number) => void;
+ rswtBdstSearch: (
+ txt: string,
+ pageNation: number,
+ code: string | number
+ ) => void;
+ rswtBdstReg: (data: customRswtBdst, code: string | number) => void;
+};
+
+export type rswtFacType = rswtFacState & rswtFacSActions;
+
+export const rswtFacStateExport: rswtFacState = {
+ rswt: {
+ isInit: false,
+ upHeadList: upHeadList,
+ rswtRes: rswtRes,
+ },
+};
+
+const initFetch = async (code: string | number) => {
+ const rswtRes = await getFetch("wr", `/reuseFc/waterreuseFc/1/10/${code}`);
+ return rswtRes;
+};
+export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
+ set: any
+) => {
+ return {
+ rswtBdstSearch: async (
+ txt: string,
+ pageNation: number,
+ code: string | number
+ ) => {
+ try {
+ const rswtRes = await getFetch(
+ "wr",
+ `/reuseFc/waterreuseFc/${pageNation}/20/${code}` +
+ (txt ? `/${txt}` : "")
+ );
+ set((state: rswtFacState) => {
+ return {
+ ...state,
+ rswt: {
+ ...state.rswt,
+ rswtRes: rswtRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ },
+ getRswtBdstData: async (pageNation: number, code: string | number) => {
+ try {
+ const rswtRes = await getFetch(
+ "wr",
+ `/reuseFc/waterreuseFc/${pageNation}/10/${code}`
+ );
+ console.log(pageNation);
+ // 여기서 상태 업데이트
+ return set((state: rswtFacState) => ({
+ ...state,
+ rswt: {
+ ...state.rswt,
+ rswtRes: rswtRes,
+ isInit: false,
+ },
+ }));
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ initRswt: async (code: string | number) => {
+ try {
+ const rswtRes = await initFetch(code);
+ return set((state: rswtFacState) => ({
+ ...state,
+ rswt: {
+ ...state.rswt,
+ rswtRes: rswtRes,
+ isInit: false,
+ },
+ }));
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ rswtBdstUpdate: async (data: customRswtBdst, code: string | number) => {
+ try {
+ const chData = await makeMdfr(data);
+ const res = await putFectch("/reuseFc/waterreuseFc", chData);
+ if (res.ok) {
+ alert("등록이 완료되었습니다.");
+ const rswtRes = await initFetch(code);
+ set((state: rswtFacState) => ({
+ ...state,
+ rswt: {
+ ...state.rswt,
+ rswtRes: rswtRes,
+ isInit: false,
+ },
+ }));
+ }
+ } catch (errorUpdate) {
+ alert(
+ "업데이트 오류입니다. " +
+ (errorUpdate instanceof Error ? errorUpdate.message : "")
+ );
+ } finally {
+ }
+ },
+ rswtBdstReg: async (data: customRswtBdst, code: string | number) => {
+ try {
+ const chData = await makeRstr(data);
+ const res = await postFectch("/reuseFc/waterreuseFc", chData);
+ if (res.ok) {
+ if (data.chgBuilding.length > 0) {
+ await res
+ .json()
+ .then((resData: any) => {
+ const chPK = resData?.data?.bdstInfoPk;
+ const makeCh = resData.data.chgBuilding.map(
+ (item: chgBuilding) => ({
+ ...item,
+ bdstInfoFk: chPK,
+ })
+ );
+ const chch = postFectch("/reuseFc/chgBuilding", makeCh);
+ return chch;
+ })
+ .then((chch: any) => {
+ if (chch.ok) {
+ alert("등록이 완료되었습니다.");
+ }
+ });
+ } else {
+ alert("등록이 완료되었습니다.");
+ }
+ }
+ const rainRes = await initFetch(code);
+ set((state: rswtFacState) => ({
+ ...state,
+ rain: {
+ ...state.rswt,
+ rswtRes: rswtRes,
+ isInit: false,
+ },
+ }));
+ } catch (e) {
+ console.log("e", e);
+ alert("등록 오류입니다.");
+ } finally {
+ }
+ },
+ };
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx
new file mode 100644
index 000000000..591623911
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx
@@ -0,0 +1,34 @@
+import type { SelectDataType } from "@common/business_components/ui";
+import type { customHtdflBdst } from "../../fcltReg/htdflReg";
+
+export const excelHtdflSttnParsing = (
+ data: customHtdflBdst[],
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+): string[][] => {
+ const excelExportData: string[][] = [];
+
+ data.forEach((item) => {
+ excelExportData.push([
+ sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
+ sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
+ item.bdstNm ?? "",
+ item.daddr ?? "",
+ String(item.frstArchPrmsnDt ?? ""),
+ String(item.reuseBuilding?.[0]?.htdflObj.etgtType ?? ""),
+ String(item.reuseBuilding?.[0]?.htdflObj.fclCpct ?? ""), // fix: added missing parenthesis
+ String(item.reuseBuilding?.[0]?.htdflObj.plwtYn ? "Y" : "N"), // fix: added missing parenthesis
+ String(item.reuseBuilding?.[0]?.htdflObj.orgwtWtritSpt ?? ""), // fix: added missing parenthesis
+ String(item.reuseBuilding?.[0]?.htdflObj.wtritEntrcTp ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj.orgwtOcrnProcs ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.amtgnr ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.prcsProcsYn ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.prcsFcltCpct ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.fmYn ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.utztnCpct ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.utztnUsg ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.emsnExitTp ?? ""), // fix: removed as it doesn't exist in the provided context
+ ]);
+ });
+ return excelExportData;
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx
new file mode 100644
index 000000000..756c47b9b
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx
@@ -0,0 +1,312 @@
+import type { z } from "zod";
+import type { sttnHeadListType } from "../rainSttn/headList";
+import type { CommonTableProps } from "@/app/store/common/type/header";
+
+export const htdflSttHeadListExport: z.infer = [
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ },
+ {
+ id: "bdstNm",
+ title: "발전소명",
+ visible: true,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ },
+ {
+ id: "frstArchPrmsnDt",
+ title: "준공년월",
+ visible: true,
+ },
+ {
+ id: "etgtType",
+ title: "발전유형",
+ visible: true,
+ },
+ {
+ id: "fclCpct",
+ title: "설비용량(KW)",
+ visible: true,
+ },
+ {
+ id: "plwtYn",
+ title: "담수화여부",
+ visible: true,
+ },
+ {
+ id: "orgwtWtritSpt",
+ title: "원수취수지점",
+ visible: true,
+ },
+ {
+ id: "wtritEntrcTp",
+ title: "취수구온도(℃)",
+ visible: true,
+ },
+
+ {
+ id: "orgwtOcrnProcs",
+ title: "원수발생공정",
+ visible: true,
+ },
+
+ {
+ id: "amtgnr",
+ title: "발생량",
+ visible: true,
+ },
+ {
+ id: "prcsProcsYn",
+ title: "처리공정여부",
+ visible: true,
+ },
+ {
+ id: "prcsFcltCpct",
+ title: "처리시설용량(m³)",
+ visible: true,
+ },
+ {
+ id: "fmYn",
+ title: "유량계여부",
+ visible: true,
+ },
+ {
+ id: "utztnCpct",
+ title: "이용량(m³)",
+ visible: true,
+ },
+ {
+ id: "utztnUsg",
+ title: "이용용도",
+ visible: true,
+ },
+
+ {
+ id: "emsnExitTp",
+ title: "배출구온도(℃)",
+ visible: true,
+ },
+
+];
+
+
+
+// id는 다확인해야함
+export const htdflSttNodeListExport: CommonTableProps[] = [
+ {
+ id: "bdnstInfo",
+ title: "1.건축물정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 5,
+ },
+ {
+ id: "htdflFcltInfo",
+ title: "2.온배수 시설현황",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 3,
+ },
+ {
+ id: "htdflMngInfo",
+ title: "3.온배수운영현황",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 11,
+ },
+
+ {
+ id: "adminDiv",
+ title: "행정구역",
+ visible: true,
+ row: 2,
+ upName: "bdnstInfo",
+ rowSpan: 1,
+ colSpan: 2,
+ },
+
+ // 3번째줄 시작
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ upName: "adminDiv",
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ upName: "adminDiv",
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ // 2번째 줄
+ // 1번째 줄 건축물정보 아래의 행으로 만들 헤더
+ {
+ id: "bdstNm",
+ title: "발전소명",
+ visible: true,
+ upName: "bdnstInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ upName: "bdnstInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "frstArchPrmsnDt",
+ title: "준공년월",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "etgtType",
+ title: "발전유형",
+ upName: "htdflFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "fclCpct",
+ title: "설비용량(KW)",
+ upName: "htdflFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "plwtYn",
+ title: "담수화여부",
+ upName: "htdflFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "orgwtWtritSpt",
+ title: "원수취수지점",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "wtritEntrcTp",
+ title: "취수구온도(℃)",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "orgwtOcrnProcs",
+ title: "원수발생공정",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "amtgnr",
+ title: "발생량",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "prcsProcsYn",
+ title: "처리공정여부",
+ upName: "prcsProcs",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "prcsFcltCpct",
+ title: "처리시설용량(m³)",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "fmYn",
+ title: "유량계여부",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "utztnCpct",
+ title: "이용량(m³)",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "utztnUsg",
+ title: "이용용도",
+ upName: "htdflMngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "emsnExitTp",
+ title: "배출구온도(℃)",
+ visible: true,
+ upName: "htdflMngInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+];
+
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx
new file mode 100644
index 000000000..dccc8719c
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx
@@ -0,0 +1,121 @@
+import type { CommonTableProps } from "@/app/store/common/type/header";
+import { htdflSttHeadListExport, htdflSttNodeListExport } from "./headList";
+import type { sttnHeadListType } from "../rainSttn/headList";
+import type { z } from "zod";
+import { controlHeadView } from "../rainSttn";
+import type { customHtdflBdst } from "../../fcltReg/htdflReg";
+import { fetchType, getFetch } from "@/components/lib/api";
+
+const htdflSttHeadList = htdflSttHeadListExport;
+const htdflSttNodeList = htdflSttNodeListExport;
+
+export type htdflSttnState = {
+ htdflSttn: {
+ isInit: boolean;
+ htdflSttHeadList: z.infer;
+ htdflSttNodeList: CommonTableProps[];
+ htdflSttnRes: customHtdflBdst[]
+ excelList: [];
+
+ };
+};
+type htdflSttnActions = {
+ initHtdfl: (con: string) => void;
+ htdflSttnSearch: (page: number, total: string, con: string) => void;
+ htdflChSttnHead: (
+ headList: z.infer,
+ ) => void;
+};
+
+export type htdflSttnType = htdflSttnState & htdflSttnActions;
+
+export const htdflSttnStateExport: htdflSttnState = {
+ htdflSttn: {
+ htdflSttHeadList: htdflSttHeadList,
+ htdflSttNodeList: htdflSttNodeList,
+ htdflSttnRes: [],
+ excelList: [],
+ isInit: false,
+ },
+};
+const initFetch = async (code: string | number) => {
+ const htdflRes = await getFetch(
+ "wr",
+ `/drain/facilityList/1/20/${code}`)
+
+ return htdflRes;
+};
+
+export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
+ set: any
+) => {
+ return {
+ initHtdfl: async (code: string | number) => {
+ try {
+ const htdflSttnRes = await initFetch(code);
+ set((state: htdflSttnState) => {
+ return {
+ ...state,
+ htdflSttn: {
+ ...state.htdflSttn,
+ htdflSttnRes: htdflSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ htdflSttnSearch: async (page: number, total: string, con: string) => {
+ try {
+ const htdflSttnRes = await getFetch(
+ fetchType.WR,
+ `/drain/facilityList/${page}/${total}/${con}`
+ );
+ if (Number(total) > 9000) {
+
+
+ set((state: htdflSttnState) => {
+
+ return {
+ ...state,
+ htdflSttn: {
+ ...state.htdflSttn,
+ excelList: htdflSttnRes,
+ },
+ };
+ });
+ } else
+ set((state: htdflSttnState) => {
+ return {
+ ...state,
+ htdflSttn: {
+ ...state.htdflSttn,
+ htdflSttnRes: htdflSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ },
+ htdflChSttnHead: async (
+ headList: z.infer
+ ): Promise => {
+
+ const changeNodeList = controlHeadView(headList, htdflSttNodeList)
+
+ return set((state: htdflSttnState) => ({
+ htdflSttn: {
+ ...state.htdflSttn,
+ htdflSttHeadList: headList,
+ htdflSttNodeList: changeNodeList,
+ },
+ }));
+ },
+
+
+ }
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx
new file mode 100644
index 000000000..8a1db05a2
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx
@@ -0,0 +1,28 @@
+import type { customPbnst } from "../../fcltReg/pbnstReg/type";
+
+export const excelPbnstSttnParsing = (data: any[]): string[][] => {
+ const excelExportData: string[][] = [];
+
+ data.forEach((item) => {
+ excelExportData.push([
+ item.rvbsn,
+ String(item.lgbsn),
+ item.mdmbsn ?? "",
+ item.rgnNm ?? "",
+ String(item.sido ?? ""),
+ String(item.gugun ?? ""),
+ String(item.bscFctNm ?? ""),
+ String(item.efflWqltStndrdNm ?? ""),
+ String(item.fctCpc ?? ""),
+ String(item.tel ?? ""),
+ String(item.ruseUtztnFcltNm ?? ""),
+ String(item.fcltCpct ?? ""),
+ String(item.splyExtraCpct ?? ""),
+ String(item.ruseCpct ?? ""),
+ String(item.usageTotal ?? ""),
+ String(item.inUsage ?? ""),
+ String(item.outUsage ?? ""),
+ ])
+ })
+ return excelExportData;
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx
new file mode 100644
index 000000000..7c2953932
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx
@@ -0,0 +1,541 @@
+import type { sttnHeadListType } from "../rainSttn/headList";
+import type {
+ CommonTableProps,
+ TableUpperProps,
+} from "@/app/store/common/type/header";
+import { z } from "zod";
+
+export const pbnSttHeadListExport: z.infer = [
+ { id: "rvbsn", title: "권역", visible: true },
+ {
+ id: "lgbsn",
+ title: "단위유역",
+ visible: true,
+ },
+ {
+ id: "mdmbsn",
+ title: "중권역",
+ visible: true,
+ },
+ { id: "rgnNm", title: "환경청", visible: true },
+ {
+ id: "sido",
+ title: "시도",
+ visible: true,
+ },
+ {
+ id: "gugun",
+ title: "시군구",
+ visible: true,
+ },
+ { id: "bscFctNm", title: "시설명", visible: true },
+ { id: "efflWqltStndrdNm", title: "지역구분", visible: true },
+
+ { id: "tel", title: "전화번호", visible: true },
+ { id: "fctCpc", title: "시설용량(톤/일)", visible: true },
+ { id: "ruseUtztnFcltNm", title: "재이용시설명", visible: true },
+
+ {
+ id: "fcltCpct",
+ title: "시설용량(m³/일)",
+ visible: true,
+ },
+ {
+ id: "splyExtraCpct",
+ title: "하수처리량(m³/일)",
+ visible: true,
+ },
+ {
+ id: "ruseCpct",
+ title: "재이용량(m³/일)",
+ visible: true,
+ },
+
+ {
+ id: "usageTotal",
+ title: "합계",
+ visible: true,
+ },
+ {
+ id: "inUsage",
+ title: "장내용수",
+ visible: true,
+ },
+ {
+ id: "outUsage",
+ title: "장외용수",
+ visible: true,
+ },
+
+ {
+ id: "operMthd",
+ title: "운영방식",
+ visible: true,
+ },
+ {
+ id: "rprtvBzenty",
+ title: "대행업체",
+ visible: true,
+ },
+ {
+ id: "bgngDt",
+ title: "시작일",
+ visible: true,
+ },
+ {
+ id: "endDt",
+ title: "종료일",
+ visible: true,
+ },
+];
+
+// id는 다확인해야함
+export const pbnstSttNodeListExport: CommonTableProps[] = [
+ {
+ id: "catchment",
+ title: "유역",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 3,
+ },
+ {
+ id: "operMngCd",
+ title: "환경청",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "adminDiv",
+ title: "행정구역",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 2,
+ },
+ {
+ id: "bdnstNm",
+ title: "시설명",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "locDiv",
+ title: "지역구분",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "tel",
+ title: "전화번호",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "fctCpc",
+ title: "시설용량(톤/일)",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "rusNm",
+ title: "재이용시설명",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "rusSup",
+ title: "재이용수공급가능량",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 3,
+ },
+ {
+ id: "yearResult",
+ title: "연간실적정보(m³)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 3,
+ },
+ {
+ id: "mngInfo",
+ title: "운영정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 4,
+ },
+ {
+ id: "a",
+ title: "권역",
+ upName: "catchment",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "aaa",
+ title: "단위유역",
+ upName: "catchment",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "aaaa",
+ title: "중권역",
+ upName: "catchment",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "cityText",
+ title: "시도",
+ upName: "adminDiv",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ upName: "adminDiv",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "fcltCpct",
+ title: "시설용량(m³/일)",
+ upName: "rusSup",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "trbt",
+ title: "하수처리량(m³/일)",
+ upName: "rusSup",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "ruseCpct",
+ title: "재이용량(m³/일)",
+ upName: "rusSup",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "total",
+ title: "합계",
+ upName: "yearResult",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "ithlWtr",
+ title: "장내용수",
+ upName: "yearResult",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "othlWtr",
+ title: "장외용수",
+ upName: "yearResult",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "mngMeth",
+ title: "운영방식",
+ upName: "mngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "rprtvBzenty",
+ title: "대행업체",
+ upName: "mngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "firstDay",
+ title: "시작일",
+ upName: "mngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "LastDay",
+ title: "종료일",
+ upName: "mngInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+];
+
+export const ruseFcltNodeListExport: TableUpperProps[] = [
+ { id: "cycl", title: "차수", visible: true, row: 1, rowSpan: 3, colSpan: 1 },
+ { id: "seCd", title: "구분", visible: true, row: 1, rowSpan: 3, colSpan: 1 },
+ {
+ id: "busiTotal",
+ title: "사업개요",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 9,
+ },
+ {
+ id: "ruseFclt",
+ title: "재처리시설",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 3,
+ },
+ {
+ id: "mainSplyPumpCpct",
+ title: "메인공급펌프용량",
+ visible: true,
+ row: 1,
+ rowSpan: 3,
+ colSpan: 1,
+ },
+ {
+ id: "buziFee",
+ title: "사업비(백만원)",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 5,
+ },
+ {
+ id: "instlAprvSncnDt",
+ title: "설치승인・인가일",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "bizCmcnDay",
+ title: "사업준공일",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "rprcsFcltCpct",
+ title: "시설용량(m³/일)",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "rprcsMthdCd",
+ title: "재처리방식",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "majorPrcsMsrcCd",
+ title: "주처리공법",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "inoutYn",
+ title: "위치처리장(내・외)",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "addr",
+ title: "위치(주소)",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ { id: "gvsbs", title: "국고", visible: true, row: 3, rowSpan: 1, colSpan: 1 },
+ {
+ id: "lcep",
+ title: "지방비",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "cusrAlotm",
+ title: "민간투자비",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ { id: "etc", title: "기타", visible: true, row: 3, rowSpan: 1, colSpan: 1 },
+ {
+ id: "totalMoney",
+ title: "합계",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+];
+
+export const ruseSplyHeadListExport: TableUpperProps[] = [
+ { id: "cycl", title: "차수", visible: true },
+ { id: "orgwtWtritQnt", title: "원수취수량", visible: true },
+ { id: "tmsYn", title: "하수처리량TMS 전후", visible: true },
+ { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후", visible: true },
+ { id: "dtlPstnExpln", title: "상세위치 설명", visible: true },
+];
+
+export const rusePplHeadListExport: TableUpperProps[] = [
+ { id: "cycl", title: "차수", visible: true },
+ { id: "ppMqlt", title: "관재질", type: "select", visible: true },
+ { id: "pdmt", title: "관경", type: "select", visible: true },
+ { id: "cpct", title: "연장", edit: true, visible: true },
+];
+
+export const ruseGuranteeHeadListExport: TableUpperProps[] = [
+ { id: "cycl", title: "차수", visible: true },
+ { id: "bod", title: "BOD(mg/L)", visible: true },
+ { id: "grssClfg", title: "총대장균군수(개/mg)", visible: true },
+ { id: "combResdch", title: "결합잔류염소(mh/L)", visible: true },
+ { id: "trbt", title: "탁도(NTU)", visible: true },
+ { id: "smll", title: "냄새", visible: true },
+ { id: "crmty", title: "색도", visible: true },
+ { id: "tn", title: "총질소(mg/L)", visible: true },
+ { id: "tph", title: "총인(mg/L)", visible: true },
+ { id: "ph", title: "수소이온농도", visible: true },
+ { id: "clIonQnt", title: "염화물(mg/L)", visible: true },
+ { id: "cdtnv", title: "전기전도도(μs/cm)", visible: true },
+];
+
+export const ruseDmdHeadListExport: TableUpperProps[] = [
+ { id: "cycl", title: "차수", visible: true },
+ { id: "dmdCoNm", title: "수요처명", visible: true },
+ { id: "daddr", title: "위치(주소)", visible: true },
+ { id: "useUsgCd", title: "사용용도", visible: true },
+ { id: "splyBgngDay", title: "공급시작일", visible: true },
+ { id: "splyEndDay", title: "공급종료일", visible: true },
+ { id: "splyCpct", title: "공급량(m³/일)", visible: true },
+ { id: "splyFmYon", title: "공급유량계 유무", visible: true },
+];
+
+export const ruseFcltHeadListExport: CommonTableProps[] = [
+ { id: "cycl", title: "차수", visible: true},
+ { id: "seCd", title: "구분", visible: true},
+ { id: "gvsbs", title: "국고", visible: true },
+ {
+ id: "lcep",
+ title: "지방비",
+ visible: true,
+ },
+ {
+ id: "cusrAlotm",
+ title: "민간투자비",
+ visible: true,
+ },
+
+ { id: "etc", title: "기타", visible: true },
+ {
+ id: "totalMoney",
+ title: "합계",
+ visible: true,
+ },
+ {
+ id: "instlAprvSncnDt",
+ title: "설치승인・인가일",
+ visible: true,
+ },
+ {
+ id: "bizCmcnDay",
+ title: "사업준공일",
+ visible: true,
+ },
+ {
+ id: "rprcsFcltCpct",
+ title: "시설용량(m³/일)",
+ visible: true,
+ },
+ {
+ id: "rprcsMthdCd",
+ title: "재처리방식",
+ visible: true,
+ },
+ {
+ id: "majorPrcsMsrcCd",
+ title: "주처리공법",
+ visible: true,
+ },
+ {
+ id: "inoutYn",
+ title: "위치처리장(내・외)",
+ visible: true,
+ },
+ {
+ id: "addr",
+ title: "위치(주소)",
+ visible: true,
+ },
+ {
+ id: "mainSplyPumpCpct",
+ title: "메인공급펌프용량",
+ visible: true,
+ },
+];
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx
new file mode 100644
index 000000000..33bce5520
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx
@@ -0,0 +1,322 @@
+import type { CommonTableProps, TableUpperProps } from "@/app/store/common/type/header";
+import type { z } from "zod";
+import { pbnSttHeadListExport, pbnstSttNodeListExport, ruseDmdHeadListExport, ruseFcltHeadListExport, ruseFcltNodeListExport, ruseGuranteeHeadListExport, rusePplHeadListExport, ruseSplyHeadListExport } from "./headList";
+import { fetchType, getFetch, postFectch } from "@/components/lib/api";
+import { controlHeadView } from "../rainSttn";
+import type { sttnHeadListType } from "../rainSttn/headList";
+import type { customPbnst, pubHasuType } from "../../fcltReg/pbnstReg/type";
+import { excelPbnstSttnParsing } from "./excel";
+import type { FcPrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
+import type { ReturnType } from "@common/business_components/ui";
+import type { WaterReuseFacility } from "./type";
+import moment from "moment";
+
+const pbnstSttHeadList = pbnSttHeadListExport;
+const pbnstSttNodeList = pbnstSttNodeListExport;
+
+export type pbnstSttnState = {
+ pbnstSttn: {
+ pbnstSttnRes: WaterReuseFacility[];
+ pbnstSearchData: WaterReuseFacility[];
+ pbnstSttHeadList: CommonTableProps[];
+ pbnstSttNodeList: CommonTableProps[];
+ pbnstDetail: customPbnst;
+ ruseFcltNodeList:TableUpperProps[]
+ ruseSplyHeadList:TableUpperProps[]
+ rusePplHeadList:TableUpperProps[]
+ ruseGuranteeHeadList:TableUpperProps[]
+ ruseDmdHeadList:TableUpperProps[]
+ ruseFcltHeadList:TableUpperProps[]
+ excelList: [];
+ isInit: boolean;
+ };
+};
+
+type pbnstSttnActions = {
+ pbnstChSttnHead: (headList: z.infer) => void;
+ pbnstSttnSearch: (
+ page: string,
+ total: string,
+ reurnValue: ReturnType,
+ searchNm: string | undefined,
+ year: string
+ ) => void;
+ pbnSttnInit: (
+ page: string,
+ total: string,
+ reurnValue: ReturnType,
+ year: string
+ ) => void;
+ getPbnStnDetail: (pbnstRuseFcltPk: string) => void;
+ pbnNmSearch: (
+ page: string,
+ total: string,
+ reurnValue: ReturnType,
+ searchNm: string | undefined,
+ year: string
+ ) => void;
+};
+
+export type pbnstSttnType = pbnstSttnState & pbnstSttnActions;
+
+export const pbnstSttnStateExport: pbnstSttnState = {
+ pbnstSttn: {
+ pbnstSttHeadList: pbnstSttHeadList,
+ pbnstSttNodeList: pbnstSttNodeList,
+ ruseFcltNodeList:ruseFcltNodeListExport,
+ ruseSplyHeadList:ruseSplyHeadListExport,
+ rusePplHeadList:rusePplHeadListExport,
+ ruseGuranteeHeadList:ruseGuranteeHeadListExport,
+ ruseDmdHeadList:ruseDmdHeadListExport,
+ ruseFcltHeadList:ruseFcltHeadListExport,
+ pbnstSttnRes: [],
+ pbnstDetail: {} as customPbnst,
+ pbnstSearchData: [],
+ excelList: [],
+ isInit: false,
+ },
+};
+
+const hasuListFetch = async (
+ page: string,
+ total: string,
+ reurnValue: ReturnType,
+ searchNm: string | undefined,
+ year: string
+) => {
+ let url = "";
+ if (reurnValue.partValue === "A") {
+ url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${
+ reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue
+ }/0/1/SW`
+ } else if (reurnValue.partValue === "R") {
+ url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${
+ reurnValue.regionValue
+ ? reurnValue.regionValue
+ : reurnValue.unitWaterShedValue
+ ? reurnValue.unitWaterShedValue
+ : reurnValue.middleRegionValue
+ }/0/1/SW`
+ } else {
+ url = `/prcsFclt/info/${page}/${total}/${reurnValue.envPartValue}/${reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue}/0/1/SW`
+
+ }
+ if( searchNm&& searchNm?.length>0){
+ url+="/"+searchNm
+ }
+ const pbnList = await getFetch(fetchType.COMMON, url);
+ const arrayList = pbnList.map((item: pubHasuType) => item.bscFctCd);
+ const getRuseList = await postFectch(
+ `/reuseFc/pubDetailList/${year}`,
+ arrayList,
+ fetchType.WR
+ );
+ const checkWrRegListRes = getRuseList.data;
+
+ const data: WaterReuseFacility[] = checkWrRegListRes.map(
+ (item: FcPrfType) => {
+ const findData = pbnList.find(
+ (fclt: pubHasuType) =>
+ fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11)
+ );
+
+ const usage = item.prfList.reduce(
+ (acc, cur) => {
+ acc.inUsage +=
+ cur.wshwtr +
+ cur.coolUswtr +
+ cur.cleanUswtr +
+ cur.drwtUswtr +
+ cur.dltnUswtr +
+ cur.ithlRswtr +
+ cur.ithlEtcUswtr +
+ cur.cleanToilUswtr +
+ cur.resn;
+ acc.outUsage +=
+ cur.lndwtr +
+ cur.hydUswtr +
+ cur.ugwtChr +
+ cur.farmUswtr +
+ cur.rvrKeepUswtr +
+ cur.indstUswtr;
+ acc.total = acc.inUsage + acc.outUsage;
+
+ return acc;
+ },
+ { total: 0, inUsage: 0, outUsage: 0 }
+ );
+
+ return {
+ rvbsn: findData?.rvbsn,
+ lgbsn: findData?.lgbsn,
+ mdmbsn: findData?.mdmbsn,
+ rgnNm: findData?.rgnNm,
+ sido: findData?.sido,
+ gugun: findData?.gugun,
+ bscFctNm: findData?.bscFctNm,
+ efflWqltStndrdNm: findData?.efflWqltStndrdNm,
+ fctCpc: findData.fctCpc,
+ tel: findData?.tel ?? "-",
+ ruseUtztnFcltNm: item.ruseUtztnFcltNm,
+ fcltCpct: item.fcltCpct,
+ splyExtraCpct: item.splyExtraCpct,
+ ruseCpct: item.ruseCpct,
+ pbnstRuseFcltPk: item.pbnstRuseFcltPk,
+ usageTotal: usage.total,
+ inUsage: usage.inUsage,
+ outUsage: usage.outUsage,
+ operMthd: item.operList[0]?.operMthd,
+ rprtvBzenty: item.operList[0]?.rprtvBzenty,
+ bgngDt: moment(item.operList[0]?.bgngDt).format("YYYY-MM-DD") ?? "",
+ endDt: moment(item.operList[0]?.endDt).format("YYYY-MM-DD") ?? "",
+ searchNm: findData.bscFctNm,
+ searchPk: findData.bscFctCd,
+ prfList:item?.prfList??[]
+ };
+ }
+ );
+ return data;
+};
+
+export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
+ set: any
+) => {
+ return {
+ pbnstChSttnHead: async (
+ headList: z.infer
+ ): Promise => {
+ const changeNodeList = controlHeadView(headList, pbnstSttNodeList);
+
+ return set((state: pbnstSttnState) => ({
+ pbnstSttn: {
+ ...state.pbnstSttn,
+ pbnstSttHeadList: headList,
+ pbnstSttNodeList: changeNodeList,
+ },
+ }));
+ },
+ pbnstSttnSearch: async (
+ page: string,
+ total: string,
+ reurnValue: ReturnType,
+ searchNm: string | undefined,
+ year: string
+ ) => {
+ try {
+ const pbnstSttnRes = await hasuListFetch(
+ page,
+ total,
+ reurnValue,
+ searchNm,
+ year
+ );
+ console.log("pbnstSttnRes", pbnstSttnRes);
+ if (Number(total) > 9000) {
+ const pbnstExcel = excelPbnstSttnParsing(pbnstSttnRes);
+ set((state: pbnstSttnState) => {
+ return {
+ ...state,
+ pbnstSttn: {
+ ...state.pbnstSttn,
+ excelList: pbnstExcel,
+ },
+ };
+ });
+ } else
+ set((state: pbnstSttnState) => {
+ return {
+ ...state,
+ pbnstSttn: {
+ ...state.pbnstSttn,
+ pbnstSttnRes: pbnstSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ },
+ pbnSttnInit: async (
+ page: string,
+ total: string,
+ reurnValue: ReturnType,
+ year: string
+ ) => {
+ try {
+
+ const pbnstSttnRes = await hasuListFetch(
+ page,
+ total,
+ reurnValue,
+ undefined,
+ year
+ );
+
+ console.log('pbnstSttnRes ', pbnstSttnRes)
+ set((state: pbnstSttnState) => {
+ return {
+ ...state,
+ pbnstSttn: {
+ ...state.pbnstSttn,
+ pbnstSttnRes: pbnstSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ },
+ getPbnStnDetail: async (pbnstRuseFcltPk: string) => {
+ try {
+ let pbnstDetail = await getFetch("wr", `/reuseFc/pubFc/${pbnstRuseFcltPk}`);
+ if(pbnstDetail.length>=0){
+ pbnstDetail= pbnstDetail.find((item: customPbnst) =>item.pbnstRuseFcltPk === pbnstRuseFcltPk)
+ }
+ console.log( 'pbnstDetail ', pbnstDetail)
+ set((state: pbnstSttnState) => {
+ return {
+ ...state,
+ pbnstSttn: {
+ ...state.pbnstSttn,
+ pbnstDetail: pbnstDetail,
+ },
+ };
+ });
+ } catch (errorHasu) {
+ console.log(errorHasu);
+ }
+ },
+ pbnNmSearch: async (
+ page: string,
+ total: string,
+ reurnValue: ReturnType,
+ searchNm: string | undefined,
+ year: string
+ ) => {
+ try {
+
+ const pbnstSttnRes = await hasuListFetch(
+ page,
+ total,
+ reurnValue,
+ searchNm,
+ year
+ );
+
+ set((state: pbnstSttnState) => {
+ return {
+ ...state,
+ pbnstSttn: {
+ ...state.pbnstSttn,
+ pbnstSearchData: pbnstSttnRes,
+ },
+ };
+ });
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ };
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/type.tsx
new file mode 100644
index 000000000..e4e86da5d
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/type.tsx
@@ -0,0 +1,27 @@
+import type { PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
+
+export type WaterReuseFacility = {
+ bscFctNm: string; // 기본시설명 (예: "난지")
+ efflWqltStndrdNm: string; // 방류수 수질 기준명 (예: "500톤 이상(Ⅲ지역)")
+ fcltCpct: number; // 시설 용량 (숫자형, 예: 1)
+ fctCpc: string; // 시설 처리 능력 (예: "2360000")
+ gugun: string; // 구군 정보 (예: " ")
+ inUsage: number; // 유입량 (예: 1387)
+ lgbsn: string; // 대수계 (예: "한강본류")
+ mdmbsn: string; // 중권역 (예: "한강서울")
+ outUsage: number; // 유출량 (예: 900)
+ pbnstRuseFcltPk: string; // 공공하수 재이용 시설 PK (예: "11000SW001R1")
+ rgnNm: string; // 관할 기관명 (예: "한강유역환경청")
+ ruseCpct: number; // 재이용 가능 용량 (예: 123)
+ ruseUtztnFcltNm: string; // 재사용 활용 시설명 (예: "난지 재사용")
+ rvbsn: string; // 소수계 (예: "한강")
+ sido: string; // 시도 정보 (예: "서울특별시")
+ splyExtraCpct: number; // 추가 공급 용량 (예: 123)
+ tel: string; // 전화번호 (예: "-")
+ usageTotal: number; // 총 사용량 (예: 2287)
+ operMthd: string;
+ rprtvBzenty: string;
+ bgngDt: string;
+ endDt: string;
+ prfList:PrfType[];
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx
new file mode 100644
index 000000000..13530a81f
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx
@@ -0,0 +1,40 @@
+import type { SelectDataType } from "@common/business_components/ui";
+import type { customRainBdst } from "../../fcltReg/rainReg";
+
+export const excelRainSttnParsing = (
+ data: customRainBdst[],
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+): string[][] => {
+ const excelExportData: string[][] = [];
+
+ data.forEach((item) => {
+ excelExportData.push([
+ sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
+ sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
+ item.bdstNm ?? "",
+ item.daddr ?? "",
+ String(item.bdstInfoPk ?? ""),
+ String(item.frstArchPrmsnDt ?? ""),
+ String(item.archArea ?? ""),
+ String(item.chgBuilding.length > 0 ? "Y" : "N"),
+ String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""),
+ String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""),
+ String(item.reuseBuilding?.[0]?.instlCst ?? ""),
+ item.reuseBuilding?.[0]?.rainyObj?.pntfColKnd ?? "",
+ String(item.reuseBuilding?.[0]?.rainyObj?.pntfColArea ?? ""),
+ String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctYn ?? ""),
+ String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctCpct ?? ""),
+ String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctPrs ?? ""),
+ String(item.reuseBuilding?.[0]?.rainyObj?.dtfcltCpct ?? ""),
+ String(item.reuseBuilding?.[0]?.instlCstSprtYn ?? ""),
+ String(item.reuseBuilding?.[0]?.instlCstSprtAmt ?? ""),
+ String(item.reuseBuilding?.[0]?.grntchBdstCertYn ?? ""),
+ String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""),
+ String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""),
+ String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "")
+ ]);
+ });
+ return excelExportData;
+};
+
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx
new file mode 100644
index 000000000..7db00678d
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx
@@ -0,0 +1,583 @@
+import type { CommonTableProps } from "@/app/store/common/type/header";
+import { z } from "zod";
+
+export const sttnHeadListType = z.array(
+ z.object({
+ id: z.string(),
+ title: z.string(),
+ visible: z.boolean(),
+ })
+);
+
+export const rainSttHeadListExport: z.infer = [
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ },
+ {
+ id: "bdstNm",
+ title: "건축물명",
+ visible: true,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ },
+ {
+ id: "bdstUsgCd",
+ title: "건축물용도코드",
+ visible: true,
+ },
+ {
+ id: "frstArchPrmsnDt",
+ title: "최초건축허가일시",
+ visible: true,
+ },
+ {
+ id: "archArea",
+ title: "건축면적",
+ visible: true,
+ },
+ {
+ id: "chBuildingYn",
+ title: "중축・개축・재축여부",
+ visible: true,
+ },
+ {
+ id: "lawTrgtYn",
+ title: "법적의무대상여부",
+ visible: true,
+ },
+ {
+ id: "instlCmptnDt",
+ title: "설치완료일시",
+ visible: true,
+ },
+
+ {
+ id: "instlCst",
+ title: "설치비용",
+ visible: true,
+ },
+
+ {
+ id: "pntfColKnd",
+ title: "집수지점종류",
+ visible: true,
+ },
+ {
+ id: "pntfColArea",
+ title: "집수지점면적",
+ visible: true,
+ },
+
+ {
+ id: "dtfcltCpct",
+ title: "저류조용량",
+ visible: true,
+ },
+ {
+ id: "filtrTrtmfctYn",
+ title: "여과처리시설유무",
+ visible: true,
+ },
+ {
+ id: "filtrTrtmfctCpct",
+ title: "여과처리시설용량",
+ visible: true,
+ },
+ {
+ id: "filtrTrtmfctPrs",
+ title: "여과처리시설처리공정",
+ visible: true,
+ },
+
+ {
+ id: "instlCstSprtYn",
+ title: "설치지원비용여부",
+ visible: true,
+ },
+ {
+ id: "instlCstSprtAmt",
+ title: "설치지원비용",
+ visible: true,
+ },
+
+ {
+ id: "grntchBdstCertYn",
+ title: "녹색건축물인증여부",
+ visible: true,
+ },
+ {
+ id: "grntchBdstCertYr",
+ title: "녹색건축물인증년도",
+ visible: true,
+ },
+ {
+ id: "grntchBdstCertNo",
+ title: "녹색건축물인증번호",
+ visible: true,
+ },
+ {
+ id: "grntchBdstCertGrd",
+ title: "녹색건축물인증등급",
+ visible: true,
+ },
+];
+
+// id는 다확인해야함
+export const rainSttNodeListExport: CommonTableProps[] = [
+ {
+ id: "bdnstInfo",
+ title: "1.건축물정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 10,
+ },
+ {
+ id: "rainFcltInfo",
+ title: "2.빗물이용시설정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 7,
+ },
+ {
+ id: "insenInfo",
+ title: "3.인센티브 정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 6,
+ },
+ {
+ id: "adminDiv",
+ title: "행정구역",
+ visible: true,
+ row: 2,
+ upName: "bdnstInfo",
+ rowSpan: 1,
+ colSpan: 2,
+ },
+
+ // 3번째줄 시작
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ upName: "adminDiv",
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ upName: "adminDiv",
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ // 2번째 줄
+ // 1번째 줄 건축물정보 아래의 행으로 만들 헤더
+ {
+ id: "bdstNm",
+ title: "건축물명",
+ visible: true,
+ upName: "bdnstInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ upName: "bdnstInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "bdstUsgCd",
+ title: "건축물용도코드",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "frstArchPrmsnDt",
+ title: "최초건축허가일시",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "archArea",
+ title: "건축면적",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "chBuildingYn",
+ title: "중축・개축・재축여부",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "lawTrgtYn",
+ title: "법적의무대상여부",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "instlCmptnDt",
+ title: "설치완료일시",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "instlCst",
+ title: "설치비용",
+ upName: "rainFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "pntfCol",
+ title: "집수면",
+ upName: "rainFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 2,
+ },
+
+ {
+ id: "pntfColKnd",
+ title: "집수지점종류",
+ upName: "pntfCol",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "pntfColArea",
+ title: "집수지점면적",
+ upName: "pntfCol",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ {
+ id: "dtfcltCpct",
+ title: "저류조용량",
+ upName: "rainFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "filtrTrtmfctYn",
+ title: "여과처리시설유무",
+ upName: "filtrTrtmfct",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "filtrTrtmfctCpct",
+ title: "여과처리시설용량",
+ upName: "filtrTrtmfct",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "filtrTrtmfctPrs",
+ title: "여과처리시설처리공정",
+ upName: "filtrTrtmfct",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ {
+ id: "filtrTrtmfct",
+ title: "여과등 처리시설",
+ visible: true,
+ upName: "insenInfo",
+ row: 2,
+ rowSpan: 1,
+ colSpan: 3,
+ },
+ {
+ id: "instlCstSprtYn",
+ title: "설치지원비용여부",
+ upName: "instlCstSprt",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "instlCstSprtAmt",
+ title: "설치지원비용",
+ upName: "instlCstSprt",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ {
+ id: "instlCstSprt",
+ title: "설치비지원",
+ upName: "insenInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 2,
+ },
+
+ {
+ id: "grntchBdstCertYn",
+ title: "녹색건축물인증여부",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCertYr",
+ title: "녹색건축물인증년도",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCertNo",
+ title: "녹색건축물인증번호",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCertGrd",
+ title: "녹색건축물인증등급",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCert",
+ title: "녹색건축물인증",
+ upName: "insenInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 4,
+ },
+];
+
+export const rainSttnDetailNodeListExport:CommonTableProps[] = [
+ { id: "totalSplyUswtrUtztnQnt",
+ title: "연간보급수이용량(m³)",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ { id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)",
+ visible: true,
+ row: 1,
+ rowSpan: 2,
+ colSpan: 1
+ },
+ { id: "useQulity",
+ title: "이용수질(필요시)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 4
+ },
+ { id: "ph", title: "PH",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1
+
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "grssClfg",
+ title: "총대장균군수",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "etc",
+ title: "기타",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ { id: "feeHistory",
+ title: "과태료부과내역",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 3
+ },
+ {
+ id: "vltnDt",
+ title: "부과일(위반일)",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "vltnMttr",
+ title: "위반사항",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "levyAmt",
+ title: "부과금액(천원)",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 1
+ },
+];
+
+export const rainSttnDetailHeadListExport:CommonTableProps[] = [
+ { id: "totalSplyUswtrUtztnQnt",
+ title: "연간보급수이용량(m³)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ { id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+ },
+
+ { id: "ph", title: "PH",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+
+ },
+ {
+ id: "trbt",
+ title: "탁도",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "grssClfg",
+ title: "총대장균군수",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "etc",
+ title: "기타",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+ },
+
+ {
+ id: "vltnDt",
+ title: "부과일(위반일)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "vltnMttr",
+ title: "위반사항",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+ },
+ {
+ id: "levyAmt",
+ title: "부과금액(천원)",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 1
+ },
+];
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx
new file mode 100644
index 000000000..5aa54ee48
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx
@@ -0,0 +1,217 @@
+import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
+import { fetchType, getFetch } from "@/components/lib/api";
+import {
+ type customRainBdst,
+} from "../../fcltReg/rainReg";
+import { excelRainSttnParsing } from "./excel";
+import {
+ rainSttHeadListExport,
+ sttnHeadListType,
+ rainSttNodeListExport,
+ rainSttnDetailHeadListExport,
+ rainSttnDetailNodeListExport,
+} from "./headList";
+import type { z } from "zod";
+import type { CommonTableProps } from "@/app/store/common/type/header";
+import type { SelectDataType } from "@common/business_components/ui";
+
+// 테이블 헤드 리스트
+const rainSttHeadList = rainSttHeadListExport;
+const rainSttNodeList = rainSttNodeListExport;
+const rainSttnDetailNodeList = rainSttnDetailNodeListExport;
+const rainSttnDetailHeadList = rainSttnDetailHeadListExport;
+
+const rainSttnRes: customRainBdst[] = [];
+const rainChkRes : rainChkZodType ={} as rainChkZodType
+
+
+const visibleHeadList = (falseHeads:CommonTableProps[], orgNodeList:CommonTableProps[])=>{
+ const visibleHeads = orgNodeList.map((node) => {
+ const copyNode = {...node}
+ falseHeads.forEach((head)=>{
+ if(copyNode.id ===head.id)
+ copyNode.visible = head.visible
+ })
+ return copyNode;
+ })
+ return visibleHeads
+}
+
+const getColspanReductionMap = (falseHeads:CommonTableProps[], orgList:CommonTableProps[]):Record => {
+ const reduceMap:Record = {};
+ falseHeads.forEach(head => {
+ const node = orgList.find(n => n.id === head.id);
+ if (node?.upName) {
+ reduceMap[node.upName] = (reduceMap[node.upName] || 0) + 1;
+ if (node.row&& node.row >= 3) {
+ const upperUpName = orgList.find(n => n.id === node.upName)?.upName;
+ if (upperUpName) {
+ reduceMap[upperUpName] = (reduceMap[upperUpName] || 0) + 1;
+ }
+ }
+ }
+ });
+ return reduceMap;
+};
+
+// colSpan 반영 및 visible 처리
+const applyColspanReduction = (
+ orgList: CommonTableProps[],
+ reduceMap: Record
+): CommonTableProps[] => {
+ return orgList.map(node => {
+ const newNode: CommonTableProps = { ...node };
+ const reduceCount = reduceMap[node.id];
+
+ if (
+ newNode.colSpan !== undefined &&
+ reduceCount !== undefined &&
+ typeof newNode.colSpan === "number"
+ ) {
+ newNode.colSpan -= reduceCount;
+ if (newNode.colSpan <= 0) {
+ newNode.visible = false;
+ }
+ }
+
+ return newNode;
+ });
+};
+// 일단 헤더가 3개 이상인경우 visible 처리를 위해서 공통함수로 작업
+export const controlHeadView = (headList:CommonTableProps[], orgNodeList:CommonTableProps[] ) =>{
+ const falseHeads = headList.filter((item) => item.visible == false);
+
+ const viewHeadList = visibleHeadList(falseHeads, orgNodeList)
+ const reduceMap= getColspanReductionMap( falseHeads,viewHeadList)
+ return applyColspanReduction(viewHeadList,reduceMap);
+}
+
+
+
+export type rainSttnState = {
+ rainSttn: {
+ rainSttnRes: customRainBdst[];
+ rainSttHeadList: CommonTableProps[];
+ rainSttNodeList: CommonTableProps[];
+ rainSttnDetailHeadList:CommonTableProps[]
+ rainSttnDetailNodeList:CommonTableProps[]
+ rainChkRes:rainChkZodType
+ excelList: [];
+ isInit: boolean;
+ };
+};
+type rainSttnActions = {
+ rainSttnInit:(con:string) => void
+ rainSttnSearch: (page: number, total: string, con: string, sidoCode: SelectDataType[], sggCode: SelectDataType[]) => void;
+ rainChSttnHead: (
+ headList: z.infer,
+ ) => void;
+ rainSttnChkSearch:(rusePk:string) => void;
+};
+
+export type rainSttnType = rainSttnState & rainSttnActions;
+
+export const rainSttnStateExport: rainSttnState = {
+ rainSttn: {
+ rainSttHeadList: rainSttHeadList,
+ rainSttNodeList: rainSttNodeList,
+ rainSttnDetailHeadList:rainSttnDetailHeadList,
+ rainSttnDetailNodeList:rainSttnDetailNodeList,
+ rainSttnRes: rainSttnRes,
+ rainChkRes:rainChkRes,
+ excelList: [],
+ isInit: false,
+ },
+};
+
+export const rainSttnActionsExport: (set: any) => rainSttnActions = (
+ set: any
+) => {
+ return {
+ rainSttnInit: async( con:string)=>{
+ try{
+
+ const rainSttnRes = await getFetch(
+ fetchType.WR,
+ `/reuseFc/rainyInfoList/1/20/${con}`
+ );
+ set((state: rainSttnState) => {
+ return {
+ ...state,
+ rainSttn: {
+ ...state.rainSttn,
+ rainSttnRes: rainSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ }catch(e){
+ console.log(e)
+ }
+ },
+ rainSttnSearch: async (page: number, total: string, con: string,
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]) => {
+ try {
+ const rainSttnRes = await getFetch(
+ fetchType.WR,
+ `/reuseFc/rainyInfoList/${page}/${total}/${con}`
+ );
+ if (Number(total) > 9000) {
+ const rainExcel = excelRainSttnParsing(rainSttnRes, sidoCode, sggCode);
+ set((state: rainSttnState) => {
+ return {
+ ...state,
+ rainSttn: {
+ ...state.rainSttn,
+ excelList: rainExcel,
+ },
+ };
+ });
+ } else
+ set((state: rainSttnState) => {
+ return {
+ ...state,
+ rainSttn: {
+ ...state.rainSttn,
+ rainSttnRes: rainSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ },
+ rainChSttnHead: async (
+ headList: z.infer
+ ) => {
+ const changeNodeList= controlHeadView(headList,rainSttNodeList)
+
+ return set((state: rainSttnState) => ({
+ rainSttn: {
+ ...state.rainSttn,
+ rainSttHeadList: headList,
+ rainSttNodeList: changeNodeList,
+ },
+ }));
+ },
+ rainSttnChkSearch: async(
+ rusePk:string
+ )=>{
+ const rainChkRes = await getFetch(
+ fetchType.WR,
+ `/reuseChk/rainy/${rusePk}`
+ );
+
+ return set((state: rainSttnState) =>({
+ rainSttn: {
+ ...state.rainSttn,
+ rainChkRes:rainChkRes
+ },
+
+ }) )
+ }
+
+ };
+};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx
new file mode 100644
index 000000000..ac57a8016
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx
@@ -0,0 +1,40 @@
+import type { SelectDataType } from "@common/business_components/ui";
+import type { customRswtBdst } from "../../fcltReg/rswtReg";
+import { useWrStore } from "@/app/store";
+
+export const excelRSwtSttnParsing = (
+ data: customRswtBdst[],
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+): string[][] => {
+ const excelExportData: string[][] = [];
+
+ data.forEach((item) => {
+ excelExportData.push([
+ sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
+ sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
+ item.bdstNm ?? "",
+ item.daddr ?? "",
+ String(item.bdstUsgText ?? ""),
+ String(item.frstArchPrmsnDt ?? ""),
+ String(item.archArea ?? ""),
+ String(item.reuseBuilding?.[0]?.rswtrObj.wtrUsqty ?? "0"), //물사용량
+ String(item.chgBuilding.length > 0 ? "Y" : "N"), //중축・개축・재축여부
+ String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""), //법적의무대상여부
+ String(item.reuseBuilding?.[0]?.rswtrObj.oblgTrgtWtrUsqty ?? ""), //의무대상물사용량
+ String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""), //설치완료일시
+ String(item.reuseBuilding?.[0]?.instlCst ?? ""), //설치비용
+ item.reuseBuilding?.[0]?.rswtrObj?.orgwtKndCd ?? "", //원수종류
+ String(item.reuseBuilding?.[0]?.rswtrObj.filtrTrtmfctCpct ?? ""), //처리시설용량
+ String(item.reuseBuilding?.[0]?.rswtrObj?.filtrTrtmfctProcs ?? ""), //주요처리공정
+ String(item.reuseBuilding?.[0]?.rswtrObj?.filtrTrtmfctUsgCd ?? ""), //이용용도
+ String(item.reuseBuilding?.[0]?.instlCstSprtYn ?? ""), //설치지원비용여부
+ String(item.reuseBuilding?.[0]?.instlCstSprtAmt ?? ""), //설치지원비용
+ String(item.reuseBuilding?.[0]?.grntchBdstCertYn ?? ""),
+ String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""),
+ String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""),
+ String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "")
+ ]);
+ });
+ return excelExportData;
+};
\ No newline at end of file
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx
new file mode 100644
index 000000000..804617ad8
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx
@@ -0,0 +1,400 @@
+import type { z } from "zod";
+import type { sttnHeadListType } from "../rainSttn/headList";
+import type { CommonTableProps } from "@/app/store/common/type/header";
+
+export const rswtSttHeadListExport: z.infer = [
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ },
+ {
+ id: "bdstNm",
+ title: "건축물명",
+ visible: true,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ },
+ {
+ id: "bdsgUsgText",
+ title: "건축물용도",
+ visible: true,
+ },
+ {
+ id: "frstArchPrmsnDt",
+ title: "최초건축허가일시",
+ visible: true,
+ },
+ {
+ id: "archArea",
+ title: "건축면적",
+ visible: true,
+ },
+ {
+ id: "wtrUsqty",
+ title: "물사용량",
+ visible: true,
+ },
+ {
+ id: "chBuildingYn",
+ title: "중축・개축・재축여부",
+ visible: true,
+ },
+
+ {
+ id: "lawTrgtYn",
+ title: "법적의무대상여부",
+ visible: true,
+ },
+
+ {
+ id: "oblgTrgtWtrUsqty",
+ title: "의무대상물사용량 ",
+ visible: true,
+ },
+ {
+ id: "instlCmptnDt",
+ title: "설치완료일시",
+ visible: true,
+ },
+ {
+ id: "instlCst",
+ title: "설치비용",
+ visible: true,
+ },
+
+ {
+ id: "orgwtKndCd",
+ title: "원수종류",
+ visible: true,
+ },
+
+ {
+ id: "filtrTrtmfctCpct",
+ title: "처리시설용량",
+ visible: true,
+ },
+ {
+ id: "filtrTrtmfctProcs",
+ title: "주요처리공정",
+ visible: true,
+ },
+ {
+ id: "filtrTrtmfctUsgCd",
+ title: "이용용도",
+ visible: true,
+ },
+
+ {
+ id: "instlCstSprtYn",
+ title: "설치지원비용여부",
+ visible: true,
+ },
+ {
+ id: "instlCstSprtAmt",
+ title: "설치지원비용",
+ visible: true,
+ },
+
+ {
+ id: "grntchBdstCertYn",
+ title: "녹색건축물인증여부",
+ visible: true,
+ },
+ {
+ id: "grntchBdstCertYr",
+ title: "녹색건축물인증년도",
+ visible: true,
+ },
+ {
+ id: "grntchBdstCertNo",
+ title: "녹색건축물인증번호",
+ visible: true,
+ },
+ {
+ id: "grntchBdstCertGrd",
+ title: "녹색건축물인증등급",
+ visible: true,
+ },
+];
+
+// id는 다확인해야함
+export const rswtSttNodeListExport: CommonTableProps[] = [
+ {
+ id: "bdnstInfo",
+ title: "1.건축물정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 12,
+ },
+ {
+ id: "rswtFcltInfo",
+ title: "2.중수도시설정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 5,
+ },
+ {
+ id: "insenInfo",
+ title: "3.인센티브 정보",
+ visible: true,
+ row: 1,
+ rowSpan: 1,
+ colSpan: 6,
+ },
+ {
+ id: "adminDiv",
+ title: "행정구역",
+ visible: true,
+ row: 2,
+ upName: "bdnstInfo",
+ rowSpan: 1,
+ colSpan: 2,
+ },
+
+ // 3번째줄 시작
+ {
+ id: "cityText",
+ title: "시도",
+ visible: true,
+ upName: "adminDiv",
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "sggText",
+ title: "시군구",
+ visible: true,
+ upName: "adminDiv",
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ // 2번째 줄
+ // 1번째 줄 건축물정보 아래의 행으로 만들 헤더
+ {
+ id: "bdstNm",
+ title: "건축물명",
+ visible: true,
+ upName: "bdnstInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "daddr",
+ title: "주소",
+ visible: true,
+ upName: "bdnstInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "bdsgUsgText",
+ title: "건축물용도",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "frstArchPrmsnDt",
+ title: "최초건축허가일시",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "archArea",
+ title: "건축면적",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "wtrUsqty",
+ title: "물사용량",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "chBuildingYn",
+ title: "중축・개축・재축여부",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "lawTrgtYn",
+ title: "법적의무대상여부",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "oblgTrgtWtrUsqty",
+ title: "의무대상물사용량",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "instlCmptnDt",
+ title: "설치완료일시",
+ upName: "bdnstInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "instlCst",
+ title: "설치비용",
+ upName: "rswtFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "orgwtKndCd",
+ title: "원수종류",
+ upName: "rswtFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "filtrTrtmfctCpct",
+ title: "처리시설용량",
+ upName: "rswtFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "filtrTrtmfctProcs",
+ title: "주요처리공정",
+ upName: "rswtFcltInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+
+ {
+ id: "filtrTrtmfctUsgCd",
+ title: "이용용도",
+ visible: true,
+ upName: "rswtFcltInfo",
+ row: 2,
+ rowSpan: 2,
+ colSpan: 1,
+ },
+ {
+ id: "instlCstSprtYn",
+ title: "설치지원비용여부",
+ upName: "instlCstSprt",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "instlCstSprtAmt",
+ title: "설치지원비용",
+ upName: "instlCstSprt",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+
+ {
+ id: "instlCstSprt",
+ title: "설치비지원",
+ upName: "insenInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 2,
+ },
+
+ {
+ id: "grntchBdstCertYn",
+ title: "녹색건축물인증여부",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCertYr",
+ title: "녹색건축물인증년도",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCertNo",
+ title: "녹색건축물인증번호",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCertGrd",
+ title: "녹색건축물인증등급",
+ upName: "grntchBdstCert",
+ visible: true,
+ row: 3,
+ rowSpan: 1,
+ colSpan: 1,
+ },
+ {
+ id: "grntchBdstCert",
+ title: "녹색건축물인증",
+ upName: "insenInfo",
+ visible: true,
+ row: 2,
+ rowSpan: 1,
+ colSpan: 4,
+ },
+];
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx
new file mode 100644
index 000000000..301cd965e
--- /dev/null
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx
@@ -0,0 +1,128 @@
+import type { CommonTableProps } from "@/app/store/common/type/header";
+import { fetchType, getFetch } from "@/components/lib/api";
+import type { z } from "zod";
+import type { customRswtBdst } from "../../fcltReg/rswtReg";
+import { controlHeadView } from "../rainSttn";
+import type { sttnHeadListType } from "../rainSttn/headList";
+import { excelRSwtSttnParsing } from "./excel";
+import { rswtSttHeadListExport, rswtSttNodeListExport } from "./headList";
+import type { SelectDataType } from "@common/business_components/ui";
+
+
+
+// 테이블 헤드 리스트
+const rswtSttNodeList = rswtSttNodeListExport;
+const rswtSttHeadList = rswtSttHeadListExport;
+const rswtSttnRes: customRswtBdst[] = [];
+
+
+
+export type rswtSttnState = {
+ rswtSttn: {
+ rswtSttnRes: customRswtBdst[];
+ rswtSttHeadList: CommonTableProps[];
+ rswtSttNodeList: CommonTableProps[];
+ excelList: [];
+ isInit: boolean;
+ };
+};
+
+type rswtSttnActions = {
+ rswtSttnInit: (con: string) => void;
+ rswtSttnSearch: (page: number, total: string, con: string, sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]) => void;
+ rswtChSttnHead: (
+ headList: z.infer,
+ ) => void;
+};
+
+export type rswtSttnType = rswtSttnState & rswtSttnActions;
+
+export const rswtSttnStateExport: rswtSttnState = {
+ rswtSttn: {
+ rswtSttHeadList: rswtSttHeadList,
+ rswtSttNodeList: rswtSttNodeList,
+ rswtSttnRes: rswtSttnRes,
+ excelList: [],
+ isInit: false,
+ },
+};
+
+
+
+export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
+ set: any
+) => {
+ return {
+ rswtSttnInit: async (con: string) => {
+ try {
+
+ const rswtSttnRes = await getFetch(
+ fetchType.WR,
+ `/reuseFc/waterreuseFc/1/20/${con}`
+ );
+ set((state: rswtSttnState) => {
+ return {
+ ...state,
+ rswtSttn: {
+ ...state.rswtSttn,
+ rswtSttnRes: rswtSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (e) {
+ console.log(e)
+ }
+ },
+ rswtSttnSearch: async (page: number, total: string, con: string,
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]) => {
+ try {
+ const rswtSttnRes = await getFetch(
+ fetchType.WR,
+ `/reuseFc/waterreuseFc/${page}/${total}/${con}`
+ );
+ if (Number(total) > 9000) {
+ const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, sidoCode, sggCode);
+ set((state: rswtSttnState) => {
+ return {
+ ...state,
+ rswtSttn: {
+ ...state.rswtSttn,
+ excelList: rswtExcel,
+ },
+ };
+ });
+ } else
+ set((state: rswtSttnState) => {
+
+ return {
+ ...state,
+ rswtSttn: {
+ ...state.rswtSttn,
+ rswtSttnRes: rswtSttnRes,
+ isInit: false,
+ },
+ };
+ });
+ } catch (erTxt) {
+ console.log("error", erTxt);
+ }
+ },
+ rswtChSttnHead: async (
+ headList: z.infer
+ ): Promise => {
+
+ const changeNodeList = controlHeadView(headList, rswtSttNodeList)
+
+ return set((state: rswtSttnState) => ({
+ rswtSttn: {
+ ...state.rswtSttn,
+ rswtSttHeadList: headList,
+ rswtSttNodeList: changeNodeList,
+ },
+ }));
+ },
+ };
+};
diff --git a/apps/wr/app/store/stats/matStat/headList.tsx b/apps/wr/app/store/stats/matStat/headList.tsx
new file mode 100644
index 000000000..881662774
--- /dev/null
+++ b/apps/wr/app/store/stats/matStat/headList.tsx
@@ -0,0 +1,68 @@
+import type { TableUpperProps } from "../../common/type/header";
+
+export const matStatHeadListExport :TableUpperProps[]=[
+ {
+ id: "시도",
+ title: "시도",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "개소",
+ title: "개소",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "요구수량",
+ title: "요구수량",
+ row:0,
+ rowSpan:2
+ },
+
+
+ {
+ id: "용도",
+ title: "용도",
+ row:0,
+ colSpan:6
+ },
+ {
+ id: "조경용수",
+ title: "조경용수",
+ row:1,
+ },
+ {
+ id: "청소화장실용수",
+ title: "청소화장실용수",
+ row:1,
+ },
+ {
+ id: "농업용수",
+ title: "농업용수",
+ row:1,
+ },
+ {
+ id: "공업용수",
+ title: "공업용수",
+ row:1,
+ },
+ {
+ id: "친수용수",
+ title: "친수용수",
+ row:1,
+ },
+ {
+ id: "기타",
+ title: "기타",
+ row:1,
+ },
+ {
+ id: "사업비",
+ title: "사업비(천원)",
+ row:0,
+ rowSpan:2
+ },
+
+
+]
\ No newline at end of file
diff --git a/apps/wr/app/store/stats/matStat/index.tsx b/apps/wr/app/store/stats/matStat/index.tsx
new file mode 100644
index 000000000..3f2e5813f
--- /dev/null
+++ b/apps/wr/app/store/stats/matStat/index.tsx
@@ -0,0 +1,28 @@
+import type { TableUpperProps } from "../../common/type/header";
+import { matStatHeadListExport } from "./headList";
+
+type matStatActions = {
+}
+
+
+export type matStatState = {
+ matStat: {
+ matStatHeadList:TableUpperProps[]
+ }
+}
+
+export type matStatType = matStatState & matStatActions;
+
+export const matStatExport: matStatState = {
+ matStat: {
+ matStatHeadList:matStatHeadListExport
+ }
+}
+
+export const matStatActionsExport: (set: any) => matStatActions = (
+ set: any
+) => {
+ return {
+
+ }
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/stats/rainStat/excel.tsx b/apps/wr/app/store/stats/rainStat/excel.tsx
new file mode 100644
index 000000000..db2099d9a
--- /dev/null
+++ b/apps/wr/app/store/stats/rainStat/excel.tsx
@@ -0,0 +1,41 @@
+import type { RainStatProps } from ".";
+
+export const excelRainStat = (excelList:RainStatProps[]) : (string | number)[][] => {
+ const excelData: (string | number)[][] = [];
+ excelList.forEach((item) => {
+ excelData.push([
+ //시도
+ item.ctpvCd ?? "",
+ //시군구
+ item.sggCd ?? "",
+ //행정구역명
+ String(item.areaNm) ?? "",
+ //시설명
+ String(item.bdstNm) ?? "",
+ //건축물용도코드 (값 없음)
+ //String(item.bdstUsgCd) ?? "",
+ "",
+ //주소
+ String(item.daddr) ?? "",
+ //법적의무대상여부
+ String(item.lawTrgtYn)==="Y" ? "대상" : "미대상",
+ //설치완료일자
+ String(item.instlCmptnDt).substring(0, 10) ?? "",
+ //설치비용
+ item.instlCst ?? "",
+ //접수면종류
+ String(item.pntfColKnd) ?? "",
+ //여과등처리시설유무
+ String(item.filtrTrtmfctYn) ?? "",
+ //처리용량(저류조용량)
+ item.dtfcltCpct ?? "",
+ //연간사용량
+ item.wtrUsqty ?? "",
+ //이용용도코드
+ item.utztnUsgCd ?? "",
+ //연간운영비
+ item.anlOperCst ?? "",
+ ]);
+ });
+ return excelData;
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/stats/rainStat/headList.tsx b/apps/wr/app/store/stats/rainStat/headList.tsx
new file mode 100644
index 000000000..664e060c4
--- /dev/null
+++ b/apps/wr/app/store/stats/rainStat/headList.tsx
@@ -0,0 +1,151 @@
+import type { TableUpperProps } from "../../common/type/header";
+
+export const rainStatHeadListExport: TableUpperProps[] = [
+ {
+ id: "ctpvCd",
+ title: "시도",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "tmp",
+ title: "개소",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "instlCst",
+ title: "설치비(백만원)",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "dtfcltCpct",
+ title: "저류조용량(m³/년)",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "wtrUsqty",
+ title: "연간사용량(㎥/년)",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "a",
+ title: "이용용도",
+ row:0,
+ colSpan:7
+ },
+ {
+ id: "lndwtr",
+ title: "조경용수",
+ row:1,
+ },
+ {
+ id: "cleanToilUswtr",
+ title: "청소화장실용수",
+ row:1,
+ },
+ {
+ id:"resn",
+ title:"세척살수용수",
+ row:1,
+ },
+ {
+ id: "farmUswtr",
+ title: "농업용수",
+ row:1,
+ },
+ {
+ id: "indstUswtr",
+ title: "공업용수",
+ row:1,
+ },
+ {
+ id: "hydUswtr",
+ title: "친수용수",
+ row:1,
+ },
+ {
+ id: "ithlEtcUswtr",
+ title: "기타",
+ row:1,
+ },
+ {
+ id: "anlOperCst",
+ title: "연간운영비(백만원/년)",
+ row:0,
+ rowSpan:2
+ },
+];
+
+export const rainStatDetailHeadListExport: TableUpperProps[] = [
+ {
+ id: "ctpvCd",
+ title: "시도",
+ row:0,
+ },
+ {
+ id: "sggCd",
+ title: "시군구",
+ row:0,
+ },
+ {
+ id: "areaNm",
+ title: "행정구역명",
+ row:0,
+ },
+ {
+ id: "",
+ title: "시설명",
+ row:0,
+ },
+ {
+ id: "이용용도",
+ title: "이용용도",
+ row:0,
+ colSpan:7
+ },
+ {
+ id: "조경용수",
+ title: "조경용수",
+ row:1,
+ },
+ {
+ id: "청소화장실용수",
+ title: "청소화장실용수",
+ row:1,
+ },
+ {
+ id:"세척살수용수",
+ title:"세척살수용수",
+ row:1,
+ },
+ {
+ id: "농업용수",
+ title: "농업용수",
+ row:1,
+ },
+ {
+ id: "공업용수",
+ title: "공업용수",
+ row:1,
+ },
+ {
+ id: "친수용수",
+ title: "친수용수",
+ row:1,
+ },
+ {
+ id: "기타",
+ title: "기타",
+ row:1,
+ },
+ {
+ id: "연간운영비",
+ title: "연간운영비(백만원/년)",
+ row:0,
+ rowSpan:2
+ },
+];
\ No newline at end of file
diff --git a/apps/wr/app/store/stats/rainStat/index.tsx b/apps/wr/app/store/stats/rainStat/index.tsx
new file mode 100644
index 000000000..d6e48a53e
--- /dev/null
+++ b/apps/wr/app/store/stats/rainStat/index.tsx
@@ -0,0 +1,184 @@
+import { fetchType, getFetch } from "@/components/lib/api";
+import type { TableUpperProps } from "../../common/type/header";
+import { excelRainStat } from "./excel";
+import { rainStatHeadListExport } from "./headList";
+
+export type RainStatProps = {
+ ctpvCd: string //시도
+ sggCd: string //시군구
+ areaNm: string //행정구역명
+ bdstNm: string //시설명
+ bdstUsgCd: string //건축물용도코드
+ daddr: string //주소
+ lawTrgtYn: string //법적의무대상여부
+ instlCmptnDt: string //설치완료일자
+ instlCst: number //설치비용
+ pntfColKnd: string //접수면종류
+ filtrTrtmfctYn: string //여과등처리시설유무
+ archArea: number //건축연면적
+ dtfcltCpct: number //처리용량(저류조용량)
+ wtrUsqty: number //연간사용량
+ utztnUsgCd: string //이용용도코드
+ anlOperCst: number //연간운영비
+ annRnwtQty: number //물사용량
+ jungsudo: number //중수도이용량
+ dachae: number //대체수이용량
+ lndwtr: number //조경용수
+ cleanToilUswtr: number //청소화장실용수
+ resn: number //세척살수용수
+ farmUswtr: number //농업용수
+ indstUswtr: number //공업용수
+ hydUswtr: number //친수용수
+ ithlEtcUswtr: number //기타
+ tmp: number //개소
+ guideStats: GuideStatProps[]
+}
+
+export type GuideStatProps = {
+ utztnUsgCd: string
+ splyUswtrUtztnQnt : number,
+ ruseFcltUtztnQnt: number
+}
+
+type ExcelType = {
+ [key: string]: string | number | undefined;
+};
+
+const excelDownList: ExcelType[] = [];
+
+const fetchRainStatList = async (year: string) => {
+ const res = await getFetch(fetchType.WR, `/reuseChk/rainy/stat/${year}`)
+ return res;
+}
+
+type rainStatActions = {
+ searchRainStatList: (year: string) => void
+}
+
+export type rainStatState = {
+ rainStat: {
+ rainStatHeadList: TableUpperProps[],
+ rainStatList: RainStatProps[],
+ excelList: ExcelType[]
+ rainDetailList : [][]
+ }
+}
+
+export type rainStatType = rainStatState & rainStatActions;
+
+export const rainStatExport: rainStatState = {
+ rainStat: {
+ rainStatHeadList: rainStatHeadListExport,
+ rainStatList: [],
+ excelList: [],
+ rainDetailList : []
+ }
+}
+export const rainStatActionsExport = (
+ set: (fn: (state: rainStatState) => rainStatState) => void
+) => {
+ return {
+ searchRainStatList: async (year: string) => {
+ const res = await fetchRainStatList(year);
+ const cityArr: any[] = [];
+ res.forEach((item: RainStatProps) => {
+
+ let obj = cityArr.find((e) => {
+ return e.ctpvCd == item.ctpvCd
+ })
+
+ if (obj) {
+ obj.instlCst += item.instlCst
+ obj.dtfcltCpct += item.dtfcltCpct
+ obj.wtrUsqty += item.wtrUsqty
+ obj.anlOperCst += item.anlOperCst
+ obj.tmp += 1
+ } else {
+ obj = {};
+ obj.ctpvCd = item.ctpvCd
+ obj.instlCst = item.instlCst
+ obj.tmp = 1
+ obj.dtfcltCpct = item.dtfcltCpct
+ obj.wtrUsqty = item.wtrUsqty
+ obj.anlOperCst = item.anlOperCst
+
+ cityArr.push(obj)
+ }
+
+ if (item.guideStats && item.guideStats.length > 0) {
+ item.guideStats.forEach((guide: GuideStatProps) => {
+ rainStatHeadListExport.forEach((headItem: TableUpperProps) => {
+
+ if (headItem.title == guide.utztnUsgCd) {
+ if (!obj[headItem.id] || typeof obj[headItem.id] !== "number") obj[headItem.id] = 0;
+ if (typeof obj[headItem.id] === "number") {
+
+ obj[headItem.id] += guide.ruseFcltUtztnQnt;
+ }
+ }
+ });
+ })
+ }
+ })
+
+ cityArr.forEach(item => {
+ excelDownList.push({
+ ctpvCd: item.ctpvCd,
+ tmp: item.tmp,
+ instlCst: item.instlCst, //설치비
+ dtfcltCpct: item.dtfcltCpct, //저류조용량
+ bdstUsgCd: item.bdstUsgCd, //연간사용량
+ lndwtr: item.lndwtr, //조경용수
+ cleanToilUswtr: item.cleanToilUswtr, //청소화장실용수
+ resn: item.resn, //세척살수용수
+ farmUswtr: item.farmUswtr, //농업용수
+ indstUswtr: item.indstUswtr, //공업용수
+ hydUswtr: item.hydUswtr, //친수용수
+ ithlEtcUswtr: item.ithlEtcUswtr, //기타
+ anlOperCst: item.anlOperCst, //연간운영비
+ })
+ })
+
+ //상세
+ const rainDetailList : RainStatProps[] = [];
+ res.forEach((item:RainStatProps) => {
+ const utztnUsgArray = new Array();
+ item.guideStats.forEach((guideStat) => {
+ utztnUsgArray.push(guideStat.utztnUsgCd);
+ })
+ rainDetailList.push({
+ ...item,
+ utztnUsgCd : utztnUsgArray.join(', '),
+ })
+ })
+ const excelDetailData = excelRainStat(rainDetailList);
+ /* const rainStatHeadList = data.map((item:RainStatProps) => ({
+ ...item,
+ ctpvCd:item.ctpvCd,
+ sggCd:item.sggCd,
+ areaNm:item.areaNm,
+ archArea:item.archArea,
+ dtfcltCpct:item.dtfcltCpct,
+ annRnwtQty:item.annRnwtQty,
+ jungsudo:item.jungsudo,
+ dachae:item.dachae,
+ way1:item.way1,
+ way2:item.way2,
+ way3:item.way3,
+ way4:item.way4,
+ way5:item.way5,
+ way6:item.way6,
+ way7:item.way7,
+ yearMoney:item.yearMoney,
+ })) */
+ set((state: rainStatState) => ({
+ rainStat: {
+ ...state.rainStat,
+ rainDetailList: excelDetailData as [][],
+ rainStatList: cityArr,
+ excelList: excelDownList
+ }
+ }));
+ }
+ }
+}
diff --git a/apps/wr/app/store/stats/rswtStat/excel.tsx b/apps/wr/app/store/stats/rswtStat/excel.tsx
new file mode 100644
index 000000000..35f567253
--- /dev/null
+++ b/apps/wr/app/store/stats/rswtStat/excel.tsx
@@ -0,0 +1,46 @@
+import type { RswtStatProps } from ".";
+
+export const excelRswtStat = (excelList:RswtStatProps[]) : (string | number)[][] => {
+ const excelData: (string | number)[][] = [];
+ excelList.forEach((item) => {
+ excelData.push([
+ //시도
+ String(item.ctpvCd) ?? "",
+ //시군구
+ String(item.sggCd) ?? "",
+ //행정구역명
+ String(item.areaNm) ?? "",
+ //건축물명
+ String(item.bdstNm) ?? "",
+ //건축물용도코드(빈칸)
+ //String(item.bdstUsgCd) ?? "",
+ "",
+ //주소
+ String(item.daddr) ?? "",
+ //법적의무대상여부
+ String(item.lawTrgtYn)==="Y" ? "대상" : "미대상",
+ //설치완료일자
+ item.instlCmptnDt ? String(item.instlCmptnDt).substring(0, 10) : "",
+ //가동개시일(빈칸)
+ //String(item.instlCst) ?? "",
+ "",
+ //건축물면적
+ item.archArea ?? "",
+ //처리용량
+ item.filtrTrtmfctCpct ?? "",
+ //물사용량
+ item.wtrUsqty ?? "",
+ //중수도+대체수이용량
+ item.rswtAltSum ?? "",
+ //중수도이용량
+ item.rswtrUsqty ?? "",
+ //대체수이용량
+ item.altUswtrUtztnQnt ?? "",
+ //중수도용도
+ String(item.utztnUsgCd) ?? "",
+ //연간운영비
+ item.anlOperCst ?? "",
+ ]);
+ });
+ return excelData;
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/stats/rswtStat/headList.tsx b/apps/wr/app/store/stats/rswtStat/headList.tsx
new file mode 100644
index 000000000..877089092
--- /dev/null
+++ b/apps/wr/app/store/stats/rswtStat/headList.tsx
@@ -0,0 +1,101 @@
+import type { TableUpperProps } from "../../common/type/header";
+
+export const rswtStatHeadListExport :TableUpperProps[]=[
+ {
+ id: "ctpvCd",
+ title: "시도",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "ctpvCnt",
+ title: "개소",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "a",
+ title: "시설현황",
+ row:0,
+ colSpan:2
+ },
+ {
+ id: "archArea",
+ title: "건축연면적(m³)",
+ row:1,
+ },
+ {
+ id: "filtrTrtmfctCpct",
+ title: "처리용량(m³)",
+ row:1,
+ },
+ {
+ id: "wtrUsqty",
+ title: "물사용량(m³/년)",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "rswtAltSum",
+ title: "중수도+대체수이용량(m³/년)",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "rswtrUsqty",
+ title: "중수도이용량(m³/년)",
+ row:0,
+ rowSpan:2
+ },
+ {
+ id: "altUswtrUtztnQnt",
+ title: "대체수이용량(m³/년)",
+ row:0,
+ rowSpan:2
+ },
+
+ {
+ id: "b",
+ title: "용도",
+ row:0,
+ colSpan:6
+ },
+ {
+ id: "lndwtr",
+ title: "조경용수",
+ row:1,
+ },
+ {
+ id: "cleanToilUswtr",
+ title: "청소화장실용수",
+ row:1,
+ },
+ {
+ id: "farmUswtr",
+ title: "농업용수",
+ row:1,
+ },
+ {
+ id: "indstUswtr",
+ title: "공업용수",
+ row:1,
+ },
+ {
+ id: "hydUswtr",
+ title: "친수용수",
+ row:1,
+ },
+ {
+ id: "ithlEtcUswtr",
+ title: "기타",
+ row:1,
+ },
+ {
+ id: "anlOperCst",
+ title: "연간운영비(백만원/년)",
+ row:0,
+ rowSpan:2
+ },
+
+
+]
\ No newline at end of file
diff --git a/apps/wr/app/store/stats/rswtStat/index.tsx b/apps/wr/app/store/stats/rswtStat/index.tsx
new file mode 100644
index 000000000..4e2a7ecc8
--- /dev/null
+++ b/apps/wr/app/store/stats/rswtStat/index.tsx
@@ -0,0 +1,168 @@
+import { fetchType, getFetch } from "@/components/lib/api";
+import type { TableUpperProps } from "../../common/type/header";
+import { rswtStatHeadListExport } from "./headList";
+import { excelRswtStat } from "./excel";
+
+export type RswtStatProps = {
+ ctpvCd: string //시도
+ sggCd : string //시군구
+ areaNm: string //행정구역명
+ bdstNm: string //시설명
+ daddr: string //주소
+ ctpvCnt: string //개소
+ archArea: number //건축연면적
+ filtrTrtmfctCpct: number //처리용량
+ wtrUsqty: number //물사용량
+ rswtAltSum: number //중수도+대체수이용량
+ rswtrUsqty: number //중수도이용량
+ altUswtrUtztnQnt: number //대체수이용량
+ lndwtr: number //조경용수
+ cleanToilUswtr: number //청소화장실용수
+ resn: number //세척살수용수
+ farmUswtr: number //농업용수
+ indstUswtr: number //공업용수
+ hydUswtr: number //친수용수
+ ithlEtcUswtr: number //기타
+ anlOperCst: number //연간운영비
+ guideStats: GuideStatProps[]
+ utztnUsgCd : string //이용코드
+ lawTrgtYn : string //법적의무대상여부
+ instlCmptnDt : string //설치완료일자
+}
+
+export type GuideStatProps = {
+ utztnUsgCd: string
+ ruseFcltUtztnQnt: number
+}
+
+type rswtStatActions = {
+ searchRswtStatList: (year: string) => void;
+}
+
+export type ExcelType = {
+ [key: string]: string | number | undefined;
+};
+
+const excelDownList: ExcelType[] = [];
+
+
+export type rswtStatState = {
+ rswtStat: {
+ rswtStatHeadList: TableUpperProps[];
+ rswtStatList: RswtStatProps[];
+ excelList: ExcelType[];
+ rswtDetailList: RswtStatProps[][];
+ }
+}
+
+export type rswtStatType = rswtStatState & rswtStatActions;
+
+export const rswtStatExport: rswtStatState = {
+ rswtStat: {
+ rswtStatHeadList: rswtStatHeadListExport,
+ rswtStatList: [],
+ excelList: [],
+ rswtDetailList: []
+ }
+}
+
+export const rswtStatActionsExport: (set: any) => rswtStatActions = (
+ set: any
+) => {
+ return {
+ searchRswtStatList: async (year: string) => {
+ const res = await getFetch(fetchType.WR, `/reuseChk/reuseWater/stat/${year}`)
+ const rswtStatList: RswtStatProps[] = [];
+
+ const cityArr: any[] = [];
+ res.forEach((item: RswtStatProps) => {
+ let obj = cityArr.find((e) => {
+ return e.ctpvCd == item.ctpvCd
+ })
+
+ if (obj) {
+ obj.ctpvCnt += 1
+ obj.archArea += item.archArea
+ obj.filtrTrtmfctCpct += item.filtrTrtmfctCpct
+ obj.wtrUsqty += item.wtrUsqty
+ obj.rswtAltSum += (item.rswtrUsqty + item.altUswtrUtztnQnt)
+ obj.rswtrUsqty += item.rswtrUsqty
+ obj.altUswtrUtztnQnt += item.altUswtrUtztnQnt
+ obj.anlOperCst += item.anlOperCst
+ } else {
+ obj = {};
+ obj.ctpvCd = item.ctpvCd
+ obj.ctpvCnt = 1
+ obj.archArea = item.archArea
+ obj.filtrTrtmfctCpct = item.filtrTrtmfctCpct
+ obj.wtrUsqty = item.wtrUsqty
+ obj.rswtAltSum = item.rswtrUsqty + item.altUswtrUtztnQnt
+ obj.rswtrUsqty = item.rswtrUsqty
+ obj.altUswtrUtztnQnt = item.altUswtrUtztnQnt
+ obj.anlOperCst = item.anlOperCst
+
+ cityArr.push(obj)
+ }
+
+ if (item.guideStats && item.guideStats.length > 0) {
+ item.guideStats.forEach((guide: GuideStatProps) => {
+ rswtStatHeadListExport.forEach((headItem: TableUpperProps) => {
+
+ if (headItem.title == guide.utztnUsgCd) {
+ if (!obj[headItem.id] || typeof obj[headItem.id] !== "number") obj[headItem.id] = 0;
+ if (typeof obj[headItem.id] === "number") {
+
+ obj[headItem.id] += guide.ruseFcltUtztnQnt;
+ }
+ }
+ });
+ })
+ }
+ });
+
+ cityArr.forEach(item => {
+ excelDownList.push({
+ ctpvCd: item.ctpvCd,
+ ctpvCnt: item.ctpvCnt,
+ archArea: item.archArea,
+ filtrTrtmfctCpct: item.filtrTrtmfctCpct,
+ wtrUsqty: item.wtrUsqty,
+ rswtAltSum: item.rswtAltSum,
+ rswtrUsqty: item.rswtrUsqty,
+ altUswtrUtztnQnt: item.altUswtrUtztnQnt,
+ lndwtr: item.lndwtr,
+ cleanToilUswtr: item.cleanToilUswtr,
+ farmUswtr: item.farmUswtr,
+ indstUswtr: item.indstUswtr,
+ hydUswtr: item.hydUswtr,
+ ithlEtcUswtr: item.ithlEtcUswtr,
+ anlOperCst: item.anlOperCst,
+ })
+ })
+
+ //상세
+ const rswtDetailList : RswtStatProps[] = [];
+ res.forEach((item:RswtStatProps) => {
+ const utztnUsgArray = new Array();
+ item.guideStats.forEach((guideStat) => {
+ utztnUsgArray.push(guideStat.utztnUsgCd);
+ })
+ rswtDetailList.push({
+ ...item,
+ rswtAltSum : item.rswtrUsqty + item.altUswtrUtztnQnt,
+ utztnUsgCd : utztnUsgArray.join(', '),
+ })
+ });
+
+ const excelDetailData = excelRswtStat(rswtDetailList);
+ set((state: rswtStatState) => ({
+ rswtStat: {
+ ...state.rswtStat,
+ rswtStatList: cityArr,
+ excelList: excelDownList,
+ rswtDetailList: excelDetailData
+ }
+ }));
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx
index 68ca9db7e..4557662f8 100644
--- a/apps/wr/app/store/store.tsx
+++ b/apps/wr/app/store/store.tsx
@@ -1,25 +1,225 @@
-import { createStore } from 'zustand/vanilla';
-import { pubFacActionsExport, pubFacStateExport, type pubFacState } from './publicReuseFaciltyInsert/index';
-import { rainFacActionsExport, rainFacStateExport, type rainFacState, type rainFacType } from './rainReuseFacilityInsert';
-import { rswtFacActionsExport, rswtFacStateExport, type rswtFacState, type rswtFacType } from './rswtrReuseFaciltyInsert';
-import { matDmdActionsExport, matDmdStateExport, type matDmdState, type matDmdType } from './matDmd';
+import { createStore } from "zustand/vanilla";
+import {
+ codeActionExport,
+ comCodeStateExport,
+ getCityCd,
+ getEnvPartCd,
+ getMiddleRegionCd,
+ getRegionCd,
+ getSggCd,
+ getUnitWaterShedCd,
+ type comCodeState,
+ type comCodeType,
+} from "./common/code";
+import {
+ matDmdActionsExport,
+ matDmdStateExport,
+ type matDmdState,
+ type matDmdType,
+} from "./matDmd";
+import {
+ rainChkgdnActionsExport,
+ rainChkgdnStateExport,
+ type rainChkgdnState,
+ type rainChkgdnType,
+} from "./prfmncReg/chkgdnReg/rainChkgdn";
+import {
+ rswtChkgdnActionsExport,
+ rswtChkgdnStateExport,
+ type rswtChkgdnState,
+ type rswtChkgdnType,
+} from "./prfmncReg/chkgdnReg/rswrtChkgdn";
+import {
+ bdstActionsExport,
+ bdstStateExport,
+ type bdstFulType,
+ type bdstState,
+} from "./ruseFcltMng/fcltReg/bdstReg";
+import {
+ htdflFacActionsExport,
+ htdflFacStateExport,
+ type htdflFacState,
+ type htdflFacType,
+} from "./ruseFcltMng/fcltReg/htdflReg";
+import {
+ pubFacActionsExport,
+ pubFacStateExport,
+ type pubFacState,
+ type pubFacType,
+} from "./ruseFcltMng/fcltReg/pbnstReg";
+import {
+ rainFacActionsExport,
+ rainFacStateExport,
+ type rainFacState,
+ type rainFacType,
+} from "./ruseFcltMng/fcltReg/rainReg";
+import {
+ rswtFacActionsExport,
+ rswtFacStateExport,
+ type rswtFacState,
+ type rswtFacType,
+} from "./ruseFcltMng/fcltReg/rswtReg";
+import {
+ rainSttnActionsExport,
+ rainSttnStateExport,
+ type rainSttnState,
+ type rainSttnType,
+} from "./ruseFcltMng/fcltSttn/rainSttn";
+import {
+ rswtSttnActionsExport,
+ rswtSttnStateExport,
+ type rswtSttnState,
+ type rswtSttnType,
+} from "./ruseFcltMng/fcltSttn/rswtSttn";
+import {
+ htdflSttnActionsExport,
+ htdflSttnStateExport,
+ type htdflSttnState,
+ type htdflSttnType,
+} from "./ruseFcltMng/fcltSttn/htdflSttn";
+import {
+ rainChkSttnActionsExport,
+ rainChkSttnStateExport,
+ type rainChkSttnState,
+ type rainChkSttnType,
+} from "./prfmncSttn/chkgdnSttn/rainChkgdnSttn";
+import { rswtChkStateExport, rswtChkSttnActionsExport, type rswtChkSttnState, type rswtChkSttnType } from "./prfmncSttn/chkgdnSttn/rswtChkgdnSttn";
+import { pbnstSttnActionsExport, pbnstSttnStateExport, type pbnstSttnState, type pbnstSttnType } from "./ruseFcltMng/fcltSttn/pbnstSttn";
+import { coSttnActionsExport, coSttnStateExport, type coSttnState, type coSttnType } from "./matDmd/coSttn"; // 옮겨야함
+import { searchActions, type comFcltActions, type comFcltState } from "./common/searchCode";
+import { pbnstPrfmncActionsExport, pbnstPrfmncStateExport, type pbnstPrfmncState, type pbnstPrfmncType } from "./prfmncReg/pbnstPrfmncReg";
+import { coRvwActionsExport, coRvwStateExport, type coRvwState, type coRvwType } from "./matDmd/coMatRvw";
+import { ruseHstryActionsExport, ruseHstryStateExport, type ruseHstryState, type ruseHstryType } from "./matDmd/ruseRvwHstry";
+import { pbnstPrfmncSttnActionsExport, pbnstPrfmncSttnExport, type pbnstPrfmncSttnState, type pbnstPrfmncSttnType } from "./prfmncSttn/pbnstPrfmncSttn";
+import { drgtActionsExport, drgtStateExport, type drgtState, type drgtType } from "./matDmd/drgtSttn";
+import { ruseCaseActionsExport, ruseCaseStateExport, type ruseCaseType, type ruseCaseState } from "./matDmd/ruseCaseMng";
+import { rainStatActionsExport, rainStatExport, type rainStatState, type rainStatType } from "./stats/rainStat";
+import { type rswtStatType, type rswtStatState, rswtStatExport, rswtStatActionsExport } from "./stats/rswtStat";
+import { matStatActionsExport, matStatExport, type matStatState, type matStatType } from "./stats/matStat";
+import { ldrmntActionsExport, ldrmntStateExport, type ldrmntState, type ldrmntType } from "./matDmd/ldrmntCoSttn";
+export type WrStore = comCodeType &
+ pubFacType &
+ rainFacType &
+ rswtFacType &
+ matDmdType &
+ htdflFacType &
+ bdstFulType &
+ rainChkgdnType &
+ rswtChkgdnType &
+ rainSttnType &
+ rswtSttnType &
+ htdflSttnType &
+ rainChkSttnType&
+ rswtChkSttnType&
+ pbnstSttnType&
+ comFcltActions&comFcltState&
+ coSttnType& // 옮겨야함
+ ldrmntType& // 옮겨야함
+ pbnstPrfmncType&
+ coRvwType&
+ ruseHstryType&
+ pbnstPrfmncSttnType&
+ drgtType&
+ ruseCaseType&
+ rainStatType&
+ rswtStatType&
+ matStatType
+ ;
-export type WrStore = pubFacState & rainFacType &rswtFacType &matDmdType;
-export const StoreZus = (initState: rainFacState& pubFacState & rswtFacState &matDmdState= {
- ...pubFacStateExport,
- ...rainFacStateExport,
- ...rswtFacStateExport ,
- ...matDmdStateExport
-}) => {
+export const StoreZus = (
+ initState: comCodeState &
+ rainFacState &
+ pubFacState &
+ rswtFacState &
+ matDmdState &
+ htdflFacState &
+ bdstState &
+ rainChkgdnState &
+ rswtChkgdnState &
+ rainSttnState &
+ rswtSttnState &
+ htdflSttnState &
+ rainChkSttnState&
+ rswtChkSttnState &
+ pbnstSttnState&
+ coSttnState& // 옮겨야함
+ ldrmntState& // 옮겨야함
+ pbnstPrfmncState&
+ coRvwState&
+ ruseHstryState&
+ pbnstPrfmncSttnState&
+ drgtState&
+ ruseCaseState&
+ rainStatState&
+ rswtStatState&
+ matStatState
+ = {
+ ...comCodeStateExport,
+ ...pubFacStateExport,
+ ...rainFacStateExport,
+ ...rswtFacStateExport,
+ ...matDmdStateExport,
+ ...htdflFacStateExport,
+ ...bdstStateExport,
+ ...rainChkgdnStateExport,
+ ...rswtChkgdnStateExport,
+ ...rainSttnStateExport,
+ ...rswtSttnStateExport,
+ ...htdflSttnStateExport,
+ ...rainChkSttnStateExport,
+ ...rswtChkStateExport,
+ ...pbnstSttnStateExport,
+ ...coSttnStateExport, // 옮겨야함
+ ...ldrmntStateExport, // 옮겨야함
+ ...pbnstPrfmncStateExport,
+ ...coRvwStateExport,
+ ...ruseHstryStateExport,
+ ...pbnstPrfmncSttnExport,
+ ...drgtStateExport,
+ ...ruseCaseStateExport,
+ ...rainStatExport,
+ ...rswtStatExport,
+ ...matStatExport
+ }
+) => {
return createStore()((set) => {
+ getSggCd(set);
+ getCityCd(set);
+ getRegionCd(set);
+ getMiddleRegionCd(set);
+ getUnitWaterShedCd(set);
+ getEnvPartCd(set);
return {
...initState,
+ ...searchActions(set),
...pubFacActionsExport(set),
...rainFacActionsExport(set),
...rswtFacActionsExport(set),
- ...matDmdActionsExport(set)
- }
- })
-}
-//store 등록하는 부분
\ No newline at end of file
+ ...matDmdActionsExport(set),
+ ...htdflFacActionsExport(set),
+ ...codeActionExport(set),
+ ...bdstActionsExport(set),
+ ...rainChkgdnActionsExport(set),
+ ...rswtChkgdnActionsExport(set),
+ ...rainSttnActionsExport(set),
+ ...rswtSttnActionsExport(set),
+ ...htdflSttnActionsExport(set),
+ ...rainChkSttnActionsExport(set),
+ ...rswtChkSttnActionsExport(set),
+ ...pbnstSttnActionsExport(set),
+ ...coSttnActionsExport(set), // 옮겨야함
+ ...ldrmntActionsExport(set), // 옮겨야함
+ ...pbnstPrfmncActionsExport(set),
+ ...coRvwActionsExport(set),
+ ...ruseHstryActionsExport(set),
+ ...pbnstPrfmncSttnActionsExport(set),
+ ...drgtActionsExport(set),
+ ...ruseCaseActionsExport(set),
+ ...rainStatActionsExport(set),
+ ...rswtStatActionsExport(set),
+ ...matStatActionsExport(set)
+ };
+ });
+};
+//store 등록하는 부분
diff --git a/apps/wr/app/style/PublicReuseFaciltyInsert.module.css b/apps/wr/app/style/PublicReuseFaciltyInsert.module.css
deleted file mode 100644
index 6fc6f75ee..000000000
--- a/apps/wr/app/style/PublicReuseFaciltyInsert.module.css
+++ /dev/null
@@ -1,9 +0,0 @@
-.formInsideTitle{
- background-color: gray;
- text-align: center;
-}
-
-
-
-.smallTitle{
-}
\ No newline at end of file
diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts
new file mode 100644
index 000000000..452788eb0
--- /dev/null
+++ b/apps/wr/components/lib/api/index.ts
@@ -0,0 +1,144 @@
+//8880
+
+import { CS_URL, DEV_URL_FO, DEV_URL_WR, LOCAL_URL } from "../config/";
+
+export const fetchType = { COMMON: "common", WR: "wr", LOCAL: "LOCAL" , CS: "CS" };
+
+export const getFetch = async (type: string, url: string) => {
+ const div =
+ type === fetchType.COMMON
+ ? DEV_URL_FO
+ : type === fetchType.LOCAL
+ ? LOCAL_URL
+ : type === fetchType.CS
+ ? ''
+ : DEV_URL_WR;
+
+ const response = await fetch(div + url, {
+ method: "GET",
+ headers: {
+ accept: "application/json",
+ },
+ });
+
+ if (!response.ok) {
+ console.log(`오류 발생: ${response.status}`);
+ }
+ const contentType = response.headers.get("content-type") ?? "";
+
+ if (contentType.includes("application/json")) {
+ // JSON 응답 처리
+ const res = await response.json();
+ return res.data;
+ } else {
+ // 파일 응답 처리 (ex. PDF, Excel 등)
+ const blob = await response.blob();
+ const blobUrl = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ const filename = "downloaded_file.PDF";
+
+ a.href = blobUrl;
+ a.download = filename;
+ a.click();
+ window.URL.revokeObjectURL(blobUrl);
+
+ return null; // 다운로드이므로 반환값 없음
+ }
+};
+
+export const getFetchWithCount = async (type: string, url: string) => {
+ const div =
+ type === fetchType.COMMON
+ ? DEV_URL_FO
+ : type === fetchType.LOCAL
+ ? LOCAL_URL
+ : type === fetchType.CS
+ ? ''
+ : DEV_URL_WR;
+
+ const response = await fetch(div + url, {
+ method: "GET",
+ headers: {
+ accept: "application/json",
+ },
+ });
+
+ if (!response.ok) {
+ console.log(`오류 발생: ${response.status}`);
+ }
+ const contentType = response.headers.get("content-type") ?? "";
+
+ if (contentType.includes("application/json")) {
+ // JSON 응답 처리
+ const res = await response.json();
+ return res;
+ } else {
+ // 파일 응답 처리 (ex. PDF, Excel 등)
+ const blob = await response.blob();
+ const blobUrl = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ const filename = "downloaded_file.PDF";
+
+ a.href = blobUrl;
+ a.download = filename;
+ a.click();
+ window.URL.revokeObjectURL(blobUrl);
+
+ return null; // 다운로드이므로 반환값 없음
+ }
+};
+
+export const postFectch = async (url: string, params: any, type?: string) => {
+ const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR;
+
+ const response = await fetch(div + url, {
+ method: "POST",
+ headers: {
+ accept: "application/json",
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(params),
+ });
+ if (!response.ok) {
+ throw new Error(`오류 발생: ${response.status}`);
+ }
+ return await response.json();
+};
+
+export const putFectch = async (url: string, params: any) => {
+ const response = await fetch(DEV_URL_WR + url, {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(params),
+ });
+ if (!response.ok) {
+ throw new Error(`오류 발생: ${response.status}`);
+ }
+ return response;
+};
+
+export const deleteFectch = async (url: string, params?: any, type?: string) => {
+ const div =
+ type === fetchType.COMMON
+ ? DEV_URL_FO
+ : type === fetchType.LOCAL
+ ? LOCAL_URL
+ : type === fetchType.CS
+ ? ''
+ : DEV_URL_WR;
+
+ console.log("deleteFectch url", div + url);
+ const response = await fetch(div + url, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: params?JSON.stringify(params):undefined,
+ });
+ if (!response.ok) {
+ throw new Error(`오류 발생: ${response.status}`);
+ }
+ return await response.text();
+};
\ No newline at end of file
diff --git a/apps/wr/components/lib/class/comClass.tsx b/apps/wr/components/lib/class/comClass.tsx
new file mode 100644
index 000000000..654b006d7
--- /dev/null
+++ b/apps/wr/components/lib/class/comClass.tsx
@@ -0,0 +1,4 @@
+export const formTableName = 'text-xl my-4 font-bold'
+export const commonButonSize = "sm"
+export const formH1Class = "bg-[#eaf3fb] text-xl text-center border-2 p-2 mt-4 font-medium text-gray-500"
+export const formH2Class = "text-xl my-4 underline font-bold"
diff --git a/apps/wr/components/lib/config/index.ts b/apps/wr/components/lib/config/index.ts
new file mode 100644
index 000000000..f85f7bad9
--- /dev/null
+++ b/apps/wr/components/lib/config/index.ts
@@ -0,0 +1,17 @@
+
+const LOCAL_PORT = "3001";
+const DEV_PORT = "11080";
+const DEV_PORT_NEW="11082"
+
+
+export const LOCAL_URL_WR = `http://localhost:${LOCAL_PORT}/api/v1`;
+export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`;
+// export const DEV_URL_WR = `http://192.168.0.91:8880/api/v1`;
+
+/// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`;
+export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`;
+
+
+export const LOCAL_URL = `http://localhost:${LOCAL_PORT}`;
+export const CS_URL= 'http://dev.onasys.co.kr:8000'
+export const CS_TUS_UPLOAD= "/attach-service/api/v1/tus/upload";
\ No newline at end of file
diff --git a/apps/wr/components/lib/func/TableData.tsx b/apps/wr/components/lib/func/TableData.tsx
new file mode 100644
index 000000000..dbb3aa7a6
--- /dev/null
+++ b/apps/wr/components/lib/func/TableData.tsx
@@ -0,0 +1,249 @@
+import type { TableUpperProps } from "@/app/store/common/type/header";
+import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
+import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
+import { Checkbox, Input, TableCell, TableRow } from "@common/components/ui";
+
+export const rainChkTableData = (chkData: rainChkZodType[]) => {
+ // 1. chkgdnFk + utztnUsgCd 기준 누계 정보 만들기
+ const maketotal = chkData.map((item: rainChkZodType) => {
+ const selectTotal = item.guideDetails.reduce((acc: any, cur: any) => {
+ const code = cur.utztnUsgCd;
+ const fk = cur.chkgdnFk;
+
+ const key = `${fk}_${code}`;
+ acc[key] = acc[key] || {
+ totalSplyUswtrUtztnQnt: 0,
+ totalRuseFcltUtztnQnt: 0,
+ };
+
+ acc[key].totalSplyUswtrUtztnQnt += cur.splyUswtrUtztnQnt;
+ acc[key].totalRuseFcltUtztnQnt += cur.ruseFcltUtztnQnt;
+
+ return acc;
+ }, {});
+ return selectTotal; // 모든 키: `${chkgdnFk}_${utztnUsgCd}` 형태
+ });
+
+ // 2. 누계 정보들을 하나의 객체로 합치기 (평탄화)
+ const flatTotalMap = Object.assign({}, ...maketotal);
+
+ // 3. rainyDetails에 누계 정보 주입
+
+ const updatedRainyDetails: any[] = [];
+ chkData.forEach((rd: rainChkZodType) => {
+ rd.rainyDetails.forEach((rainyItem: any) => {
+ const key = `${rainyItem.chkgdnFk}_${rainyItem.utztnUsgCd}`;
+ const totals = flatTotalMap[key] || {
+ totalSplyUswtrUtztnQnt: 0,
+ totalRuseFcltUtztnQnt: 0,
+ };
+
+ updatedRainyDetails.push({
+ ...rd,
+ ...rd.building,
+ ...rainyItem,
+ ...totals,
+ rowspan: rd.rainyDetails?.length,
+ });
+ });
+ });
+
+ return updatedRainyDetails;
+};
+
+export const rswtChkTableData = (chkData: rswtChkZodType[]) => {
+ // 1. chkgdnFk + utztnUsgCd 기준 누계 정보 만들기
+ const makeRswtData: any[] = [];
+ chkData.forEach((root) => {
+ root.rswtrDetails.forEach((detail) => {
+ let flatRswtChk = {};
+ const findGuide = root.guideDetails.find(
+ (guide) => guide.utztnUsgCd === detail.utztnUsgCd
+ );
+ const findPoluttion = root.rswtrPollutions.find(
+ (polution) => polution.utztnUsgCd === detail.utztnUsgCd
+ );
+ const operMngCd = root?.reuseBuilding.operMngCd;
+ flatRswtChk = {
+ ...root,
+ ...detail,
+ ...findGuide,
+ ...findPoluttion,
+ ...flatRswtChk,
+ operMngCd: operMngCd,
+ };
+ makeRswtData.push(flatRswtChk);
+ });
+ });
+ return makeRswtData;
+};
+
+export const chRowspanTable = (
+ makeTableData: any[],
+ headList: TableUpperProps[],
+ handleChange: (
+ rowIndex: number,
+ field: keyof (typeof makeTableData)[0],
+ value: string | number
+ ) => void,
+ toggleSelection: (pk: number, checked: boolean) => void,
+ selectedIds: number[],
+ handleCellClick: (index: number, headId: string) => void
+) => {
+ let order = 0
+ // rowspan된 셀 렌더링 여부 추적용
+ const renderedMap = new Map>();
+ return (
+ <>
+ {makeTableData.map((row, rowIndex) => (
+
+ {headList
+ .map((head) => {
+
+ const key = head.id;
+ const isMerged = head.mergeCell;
+ const value = row[key];
+ // 병합 대상이면 중복 렌더링 여부 판단
+ if (isMerged) {
+ const renderedSet = renderedMap.get(key) ?? new Set();
+ if (renderedSet.has(rowIndex)) {
+
+ return null; // 이미 렌더링된 셀은 skip
+ }
+
+ const rowspan = row.rowspan ?? 1;
+ for (let i = 0; i < rowspan; i++) {
+ renderedSet.add(rowIndex + i);
+ }
+ renderedMap.set(key, renderedSet);
+ return (
+
+ {key === "checkBox" ? (
+
+ toggleSelection(row.chkgdnPk, checked === true)
+ }
+ >
+ ) : key === "order" ? (
+ ++order
+ ) : (
+ value
+ )}
+
+ );
+ }
+
+ // 기본 셀
+ return (
+ handleCellClick(rowIndex, head.id)}
+ >
+ {head.edit === true ? (
+ {
+ handleChange(rowIndex, head.id, e.target.value);
+ }}
+ value={value ?? ""}
+ disabled={!selectedIds.includes(row.chkgdnPk)}
+ />
+ ) : (
+ (head.id === "totalSplyUswtrUtztnQnt" || head.id === "totalRuseFcltUtztnQnt" || head.id === "splyUswtrUtztnQnt" || head.id === "ruseFcltUtztnQnt") ? (
+
+ {value}
+
+ ) : (
+ <>{value}>
+ )
+ )}
+
+ );
+
+ })}
+
+ ))}
+ >
+ );
+};
+
+
+
+export const headVisibleChange = (headList: TableUpperProps[], isEdit: boolean) => {
+ return headList.forEach((head) => {
+ if (head.edit !== undefined)
+ head.edit = isEdit;
+ if (head.id === 'checkBox') {
+ head.visible = false
+ }
+
+ });
+}
+
+
+const handleChange = (
+ rowIndex: number,
+ field: any,
+ value: string | number,
+ setInputData: (data:any) => void
+) => {
+ if(Number(value) < 0 ||! Number(value)){
+ value = 0;
+ }else{
+ value = Number(value);
+ }
+ setInputData((prevData:any) =>
+ prevData?.map((row:any, index: number) => {
+ if (index === rowIndex) {
+ return {
+ ...row,
+ [field ]: value,
+ };
+ }
+ return row;
+ })
+ );
+};
+;
+
+
+
+export const InputTableBody = (chgRes: any[] | [] ,headList:TableUpperProps[], setInputData: (data: any[]) => void) => {
+ return (
+ <>
+ {chgRes.map((data, dataIndex) => (
+
+ {headList.map((head, headIndex) => (
+
+ {head.edit ===true && data.edit !==false?
+
+ handleChange(dataIndex, head.id, e.target.value,setInputData)
+ }
+ value={data[head.id as keyof any] ?? ""}
+ /> : (
+
+ {data[head.id as keyof any] ?? ""}
+
+ )
+ }
+
+ ))}
+
+ ))}
+ >
+ );
+}
\ No newline at end of file
diff --git a/apps/wr/components/lib/func/calculateConstCost .tsx b/apps/wr/components/lib/func/calculateConstCost .tsx
new file mode 100644
index 000000000..5e9387385
--- /dev/null
+++ b/apps/wr/components/lib/func/calculateConstCost .tsx
@@ -0,0 +1,101 @@
+export const findBounds = (
+ data: any[],
+ fctCd: string,
+ dataCode: string,
+ qtyCode:string,
+ qty: number
+): { lower: any; upper: any } => {
+
+
+ const filtered = data.filter((item) => item[dataCode] === fctCd);
+
+ const lowers = filtered.filter((item) => Number(item[qtyCode]) <= qty);
+ const uppers = filtered.filter((item) => Number(item[qtyCode]) > qty);
+
+ const lower =
+ lowers.length > 0
+ ? lowers.reduce((acc, curr) =>
+ Number(curr[qtyCode]) > Number(acc[qtyCode]) ? curr : acc
+ )
+ : undefined;
+
+ const upper =
+ uppers.length > 0
+ ? uppers.reduce((acc, curr) =>
+ Number(curr[qtyCode]) < Number(acc[qtyCode]) ? curr : acc
+ )
+ : undefined;
+
+ // ✅ 바운더리 하나만 있을 경우 대체 처리
+ if (!lower && upper) return { lower: upper, upper };
+ if (!upper && lower) return { lower, upper: lower };
+
+ // ✅ 정상 보간 구간
+ if (lower && upper) return { lower, upper };
+
+ // ❌ 둘 다 없을 경우 (fctCd 필터 결과가 없음)
+ throw new Error(`No matching bounds found for fctCd: ${fctCd}, qty: ${qty}`);
+};
+
+
+// (기울기) a = (y2 - y1) / (x2 - x1)
+// (절편) b = y1 - a * x1
+// ↓
+// 결과값 y = a * x + b
+
+
+export const getInterpolation = (
+ Upper: { stdCost: number; fctCpc: number },
+ Lower: { stdCost: number; fctCpc: number },
+ qtyYear: number
+): number => {
+ const x1 = Number(Lower.fctCpc); // 최소 처리 용량
+ const y1 = Number(Lower.stdCost); // 최소 공사비/요율
+ const x2 = Number(Upper.fctCpc); // 최대 처리 용량
+ const y2 = Number(Upper.stdCost); // 최대 공사비/요율
+
+ if (qtyYear <= x1) return y1; // 최소 이하면 y1 반환
+ if (qtyYear >= x2) return y2; // 최대 이상이면 y2 반환
+
+ const slope = (y2 - y1) / (x2 - x1); // 기울기 a
+ const intercept = y1 - slope * x1; // 절편 b
+
+ return slope * qtyYear + intercept; // 보간 계산
+};
+
+export const transformAndInterpolate = (
+ rawData: any,
+ dmndQtyYear: number
+): any => {
+ const result: any = {};
+
+ for (const key in rawData) {
+ const item = rawData[key];
+
+ const range = {
+ Lower: {
+ fctCpc: item.lower?.stdCost,
+ stdCost: item.lower?.rt,
+ },
+ Upper: {
+ fctCpc: item.upper?.stdCost,
+ stdCost: item.upper?.rt,
+ },
+ };
+ result[key] = getInterpolation(range.Upper, range.Lower, dmndQtyYear);
+ }
+
+ return result;
+};
+
+export const getConstFctCode = (fctCd: string) => {
+ const fctMap: { [key: string]: string } = {
+ 총인처리시설: "001",
+ 염소소독: "002",
+ UV소독: "003",
+ 전처리시설: "004",
+ RO: "005",
+ };
+
+ return fctMap[fctCd];
+};
diff --git a/apps/wr/components/lib/func/commom.tsx b/apps/wr/components/lib/func/commom.tsx
new file mode 100644
index 000000000..e5dfc8c0c
--- /dev/null
+++ b/apps/wr/components/lib/func/commom.tsx
@@ -0,0 +1,161 @@
+import type { comCodeState } from "@/app/store/common/code";
+import {
+ filePickedBlob,
+ type SelectDataType,
+ type ReturnType,
+ filePickedBlobArray,
+ type SheetParameter,
+} from "@common/business_components/ui";
+import type { RefObject } from "react";
+
+export const getCity = (val: string, sggCd: SelectDataType[]) => {
+ const data = sggCd
+ .filter((item) => String(item.val).substring(0, 2) === val)
+ .map((item) => ({
+ val: item.val,
+ text: item.text, // 한국어 텍스트
+ }));
+ data.unshift({ val: "0", text: "전체" });
+ return data;
+};
+
+// cd text 넣기
+export const tableData = (data: any, code: comCodeState) => {
+ const chCode = code.code;
+
+ return data?.map(
+ (item: {
+ sggCd: string;
+ ctpvCd: string;
+ reuseBuilding: { lawTrgtYn: any; bdstUsgCd: any }[];
+ }) => {
+ let returnData = {};
+ const sggText = chCode.sggCd.find(
+ (cd) => cd.val === String(item.sggCd).trim()
+ )?.text;
+ const cityText = chCode.cityCd.find(
+ (cd) => cd.val === String(item.ctpvCd).trim()
+ )?.text;
+ if (item?.reuseBuilding?.length > 0) {
+ const bdsgUsgText = chCode.bdstUsgCd.find(
+ (cd) => Number(cd.val) === item?.reuseBuilding[0]?.bdstUsgCd
+ )?.text;
+ const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn;
+ returnData = {
+ ...item,
+ sggText: sggText ?? "없음",
+ cityText: cityText ?? "없음",
+ bdsgUsgText: bdsgUsgText,
+ lawTrgtYn: lawTrgtYn,
+ };
+ } else {
+ returnData = {
+ ...item,
+ sggText: sggText ?? "없음",
+ cityText: cityText ?? "없음",
+ };
+ }
+ return returnData;
+ }
+ );
+};
+
+export const excelDownload = (
+ excelList: [][],
+ fileNm: string,
+ sampleFile: string,
+ headerRange = "A1:V3",
+ writeLine = 4
+) => {
+ if (excelList.length === 0) return;
+ fetch(`/${sampleFile}`, {}).then(async (response) => {
+ if (!response.ok) {
+ throw Error(response.statusText);
+ }
+ // 받은 파일 바인너리 처리
+ const blobRet = await response.arrayBuffer();
+ // 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
+ await filePickedBlob(blobRet, excelList, fileNm, writeLine, headerRange);
+ });
+};
+
+export const excelArrayDownload = (
+ fileNm: string,
+ sampleFile: string,
+ sheetArray:SheetParameter []
+) => {
+ if (!sheetArray) return;
+ fetch(`/${sampleFile}`, {}).then(async (response) => {
+ if (!response.ok) {
+ throw Error(response.statusText);
+ }
+ // 받은 파일 바인너리 처리
+ const blobRet = await response.arrayBuffer();
+ // 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
+ await filePickedBlobArray(blobRet, fileNm, sheetArray);
+ });
+};
+
+// onchange 텍스트를 숫자로 and ,제거
+export const handleCommaNumberChange = (
+ e: React.ChangeEvent,
+ onChange: (value: number | "") => void
+) => {
+ const raw = e.target.value.replace(/,/g, "");
+ if (!/^\d*$/.test(raw)) return;
+ onChange(raw === "" ? "" : Number(raw));
+};
+
+// 숫자입력시 , 삽입
+export const formatCommaNumber = (
+ value: number | string | undefined | null
+): string => {
+ if (value === undefined || value === null || value === "") return "";
+ const num = Number(value);
+ // 숫자로 변환할 수 없는 값이 들어올 경우 빈 문자열을 반환하여 예상치 못한 "NaN" 출력을 방지합니다.
+ if (isNaN(num)) {
+ return "";
+ }
+ return num.toLocaleString();
+};
+
+export const getCityOrSgg = (ref: RefObject) => {
+ let con;
+ if (ref.current != null)
+ if (ref.current.sigunValue != "0") {
+ con = ref.current.sigunValue;
+ } else {
+ con = ref.current.sidoValue;
+ }
+ return con;
+};
+
+export const safeDate = (value: any): Date | undefined => {
+ const date = new Date(value);
+ return isNaN(date.getTime()) ? undefined : date;
+};
+
+const currentYear = new Date().getFullYear();
+export const yearOptions: { val: string; text: string }[] = Array.from(
+ { length: currentYear - 1969 },
+ (_, i) => ({
+ val: String(1970 + i),
+ text: `${1970 + i}년`,
+ })
+);
+
+export const getdmdMatFlag = (flag: string|undefined) => {
+ let flagMat = "";
+
+ if(flag === undefined || flag === null) {
+ flagMat = "신청";
+ }else if(flag.trim() === "Sub") {
+ flagMat = "검토";
+
+ }else if(flag.trim() === "matched") {
+ flagMat = "매칭완료";
+ }else {
+ flagMat = "신청";
+ }
+ return flagMat;
+};
diff --git a/apps/wr/components/lib/useTus_wr/useTusWr.tsx b/apps/wr/components/lib/useTus_wr/useTusWr.tsx
new file mode 100644
index 000000000..b9441e6a4
--- /dev/null
+++ b/apps/wr/components/lib/useTus_wr/useTusWr.tsx
@@ -0,0 +1,78 @@
+import {
+ Upload,
+ type HttpRequest,
+ type HttpResponse,
+ type OnSuccessPayload,
+ type DetailedError,
+} from "tus-js-client";
+import { CS_TUS_UPLOAD, CS_URL } from "../config";
+import type { FilesType } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm";
+
+type UploadOptions = {
+ handleUploadStart?: (upload: Upload) => void;
+ handleProgress?: (percentage: string) => void;
+ handleSuccess?: (payload: OnSuccessPayload) => void;
+ handleResponse?: (req: HttpRequest, res: ReturnFileType) => void;
+};
+export type ReturnFileType = {
+ orgnlFileNm: string;
+ atflFlieSz: number;
+ atflType: string;
+ dwnldNocs: number;
+ delYn: string;
+ lnkgDmnId: string | null;
+ lnkgDmnNm: string | null;
+ regDt: Date | null;
+ atflCd: String;
+ atflSn: number;
+ atflId: String;
+ physFileNm: String;
+};
+export const TusClientUpload = (oFile: FilesType, options?: UploadOptions) =>
+ new Promise((resolve, reject) => {
+ try {
+ const Authorization = "Authorization";
+ const AUTH_USER_ID = "token-id";
+ let fileInfo: string | undefined;
+ //CS_URL
+ const uploader = new Upload(oFile.file, {
+ endpoint: CS_TUS_UPLOAD,
+ chunkSize: 10 * 1024 * 1024,
+ headers: {
+ Authorization: "",
+ AUTH_USER_ID: "",
+ },
+ metadata: {
+ filename: oFile.file.name,
+ filetype: oFile.file.type,
+ },
+ onError(error) {
+ reject(error);
+ },
+ onProgress(bytesUploaded, bytesTotal) {
+ const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
+ options?.handleProgress?.(percentage);
+ },
+ onAfterResponse(req, res: HttpResponse) {
+ fileInfo = res.getHeader("X-File-Info");
+ if (fileInfo === undefined || fileInfo === null) return;
+ },
+ onSuccess(payload: OnSuccessPayload) {
+ options?.handleSuccess?.(payload);
+ if (fileInfo) {
+ console.log('fileInfo', fileInfo);
+ resolve(JSON.parse(fileInfo) as ReturnFileType);
+ } else reject({} as DetailedError);
+ },
+ });
+
+ options?.handleUploadStart?.(uploader);
+ uploader.start();
+ } catch (e) {
+ console.log(e);
+ reject(e as DetailedError);
+ }
+ // setUpload(uploader);
+ });
+//
+//
diff --git a/apps/wr/components/toastFromUi.tsx b/apps/wr/components/toastFromUi.tsx
deleted file mode 100644
index 5270ca5ec..000000000
--- a/apps/wr/components/toastFromUi.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-
-import { Button } from "@common/components/ui";
-import Link from "next/link";
-import { useRouter } from "next/router";
-import toast from "react-hot-toast";
-
-
-
-export function ToastFormUi(body:string,title:string,url:string,buttonName:string){
-
- //const router = useRouter();
-
- return(
-
- toast.custom((t) => (
-
-
-
-
-
-
-
-
-
- {title}
-
-
- {body}
-
-
-
-
-
-
-
-
-
-
-
- ))
- )
-}
\ No newline at end of file
diff --git a/apps/wr/components/ui/IteratreForm.tsx b/apps/wr/components/ui/IteratreForm.tsx
deleted file mode 100644
index 9d35d865e..000000000
--- a/apps/wr/components/ui/IteratreForm.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { FileUpload, FormControl, FormField, FormItem, FormLabel, FormMessage, SelectBox } from "@common/business_components";
-import { DatePicker } from "@common/components";
-import { Input } from "@common/components";
-
-
-export type typeOfForm ={
- labelName: string;
- type: string;
- placeholder:any;
- formName: string;
- selectValue:selectValue|undefined;
-}
-type onSelectValue = (val:string) => void;
-export type selectValue ={
- label:string,
- value:{ text: string; val: string }[],
- fun:onSelectValue
-}
-
-
-export function IteraterFrom(formData:typeOfForm[],form:any , formClass:string ){
-
- const formItem =(data:typeOfForm,field:any)=>{
- let tag
- if(data.type==='select'){
- tag= (data.selectValue ? {...form} : null)
- }else if(data.type==='date'){
- tag =()
- }else{
- tag=()
- }
- return tag;
- }
-
- return (
- <>
- {formData.map((data: typeOfForm, index) => (
- (
-
- {data.labelName}
-
- {formItem(data,field)}
-
-
-
- )}
- />
- ))}
- >
- );
- };
\ No newline at end of file
diff --git a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx
new file mode 100644
index 000000000..b22f9474e
--- /dev/null
+++ b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx
@@ -0,0 +1,467 @@
+import { useWrStore } from "@/app/store";
+import { usageProcData } from "@/app/store/matDmd/coMatRvw/headList";
+import type {
+ DedMatUpdateType,
+ DmdCoReqType,
+} from "@/app/store/matDmd/coMatRvw/type";
+import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import { formH1Class } from "@/components/lib/class/comClass";
+import {
+ findBounds,
+ getConstFctCode,
+ getInterpolation,
+ transformAndInterpolate,
+} from "@/components/lib/func/calculateConstCost ";
+import { ConstCostFeeTable } from "@/components/ui/modal/coMat/constCostFeeTable";
+import { RateFeeTableModal } from "@/components/ui/modal/coMat/rateFeeModal";
+import {
+ Form,
+ FormField,
+ FormUi,
+ UiModal,
+ UiTable,
+} from "@common/business_components/ui";
+import PopoverUi from "@common/business_components/ui/popover_ui";
+import { Button, Input, Label } from "@common/components/ui";
+import type { read } from "fs";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { type UseFormReturn } from "react-hook-form";
+import toast from "react-hot-toast";
+
+export default function ConCostForm({
+ form,
+ type,
+}: {
+ form: UseFormReturn;
+ type: string;
+}) {
+ const {
+ constCostRes,
+ rateFeeRes,
+ coMatRvwUpdate,
+ ruseRvwCalUpdate,
+ getRateFee,
+ getConstCostFee,
+ } = useWrStore((state) => state);
+
+ const ref = useRef(false);
+
+ useEffect(() => {
+ if (!ref.current) {
+ const currentYear = new Date().getFullYear();
+ getConstCostFee(String(currentYear));
+ getRateFee(String(currentYear));
+ ref.current = true;
+ }
+ }, [ref, getConstCostFee, getRateFee]);
+
+ const zipDowonLoad = () => {
+ fetch(`/2024_constarctFeeProgram.zip`, {}).then(async (response) => {
+ const blobRet = await response.blob();
+ // const blob = new Blob([blobRet], { type: "application/octet-stream" });
+ const link = document.createElement("a");
+ link.href = URL.createObjectURL(blobRet);
+ link.download =
+ "24년_수도시설 운영비 및 개략공사비 산정프로그램.zip";
+ link.click();
+ });
+ };
+ const usgPrcsProcsWatch = form.watch("demandCst.usgPrcsProcs");
+ const dmndQtyWatch = form.watch("dmndQty");
+ const totalConstCost = form.watch("totalConstCost");
+ const cstrnCst = form.watch("demandCst.cstrnCst");
+
+ const calculateConstCost = useCallback(() => {
+ const usgPrcsProcs = usgPrcsProcsWatch;
+ const dmndQtyYear = dmndQtyWatch * 365;
+ if (usgPrcsProcs && usgPrcsProcs?.length > 0) {
+ const firstProc = getConstFctCode(usgPrcsProcs?.split("+")[0] || "") || "";
+ const secondProc = getConstFctCode(usgPrcsProcs?.split("+")[1] || "") || "";
+
+ const { lower: firstLower, upper: firstUpper } = findBounds(
+ constCostRes,
+ firstProc || "",
+ 'fctCd',
+ 'fctCpc',
+ Number(dmndQtyYear)
+ );
+ const { lower: secondLower, upper: secondUpper } = findBounds(
+ constCostRes,
+ secondProc || "",
+ 'fctCd',
+ 'fctCpc',
+ Number(dmndQtyYear)
+ );
+
+ const firstConstFee = getInterpolation(
+ firstUpper,
+ firstLower,
+ dmndQtyYear
+ );
+ const secondConstFee = getInterpolation(
+ secondUpper,
+ secondLower,
+ dmndQtyYear
+ );
+ const result = Math.round(firstConstFee + secondConstFee) / 100;
+
+ const groupCodes = ["BD", "CE", "SE", "WD"];
+ const groupedBounds: { [key: string]: { lower?: any; upper?: any } } = {};
+ for (const code of groupCodes) {
+
+ groupedBounds[code] = findBounds(rateFeeRes, code, 'incExpCd', 'stdCost',result);
+ }
+ const resultRate = transformAndInterpolate(groupedBounds, result);
+ const fcltSbsdCstrnCst = (result* (resultRate.BD + resultRate.CE + resultRate.SE + resultRate.WD) / 100);
+ const realResult = result + fcltSbsdCstrnCst;
+
+ form.setValue("demandCst.prcsFcltCpctCstrnCst", Math.round(result) );
+ form.setValue("demandCst.fcltSbsdCstrnCst", Math.round(fcltSbsdCstrnCst)) ;
+ form.setValue("totalConstCost", Math.round(realResult));
+ }
+ }, [constCostRes, rateFeeRes, usgPrcsProcsWatch, dmndQtyWatch]);
+ const onSubmit = (value: DmdCoReqType) => {
+
+ if( !form.getValues('demandCst.prcsFcltCpctCstrnCst') ){
+ toast.error('공사비 계산 진행 후 저장을 눌러주새요')
+ return
+ }
+ if (type === "mat") {
+ const data: DedMatUpdateType = {
+ dmdInfoSn: form.getValues("dmdInfoSn"),
+ usgPrcsProcs: form.getValues("demandCst.usgPrcsProcs"),
+ cstrnCst: form.getValues("demandCst.cstrnCst"),
+ fcltSbsdCstrnCst: form.getValues("demandCst.fcltSbsdCstrnCst"),
+ prcsFcltCpctCstrnCst: form.getValues("demandCst.prcsFcltCpctCstrnCst"),
+ rgtr: TEST_UUID,
+ };
+ coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data);
+ } else if (type === "hist") {
+
+ delete value.totalConstCost
+ delete value.ruseUtztnFcltNm
+
+
+ ruseRvwCalUpdate(value);
+ }
+ };
+
+ useEffect(() => {
+ console.log(" form ", form.formState.errors);
+ }, [form.formState]);
+
+ return (
+ <>
+
+
+ >
+ );
+}
diff --git a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx
new file mode 100644
index 000000000..5ab5edf98
--- /dev/null
+++ b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx
@@ -0,0 +1,340 @@
+import { useWrStore } from "@/app/store";
+import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import { formH1Class } from "@/components/lib/class/comClass";
+import {
+ formatCommaNumber,
+ getCity,
+ handleCommaNumberChange,
+ safeDate,
+} from "@/components/lib/func/commom";
+import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
+import {
+ FormField,
+ FormUi,
+ DatePicker,
+ SelectBox,
+ type SelectDataType,
+} from "@common/business_components";
+import { Button, Checkbox, Input } from "@common/components";
+import { Check } from "lucide-react";
+import { useEffect, useRef, useState } from "react";
+import { useFieldArray } from "react-hook-form";
+
+export default function BdstReg({ form }: { form: any }) {
+ const { code } = useWrStore((state) => {
+ return state;
+ });
+
+ const { fields, append, remove } = useFieldArray({
+ name: "chgBuilding",
+ control: form?.control, // Provide a fallback to avoid errors
+ });
+
+ const plusHist = () => {
+ append({
+ bdstNm: "",
+ daddr: "",
+ bdstUsgCd: "",
+ });
+ };
+// 잠깐 주석처리
+ // const removeLastItem = () => {
+ // if (fields.length > 0) {
+ // remove(fields.length - 1);
+ // }
+ // };
+ const removeSelected = () => {
+ const idxsToRemove = fields
+ .map((item, idx) => selectedIds.includes(item.id) ? idx : -1)
+ .filter(index => index > -1)
+ .sort((prevIndex, nextIndex) => nextIndex - prevIndex);
+
+ remove(idxsToRemove);
+ setSelectedIds([]);
+ };
+
+
+ const [selectSgg, setSelectSgg] = useState();
+ const [objSearch, setObjSearch] = useState({
+ sgg: "",
+ city: "",
+ });
+
+ const getSelCity = (val: string) => {
+ const data = getCity(val, code.sggCd);
+ setSelectSgg(data);
+ const sgg = form.getValues("sggCd");
+
+ setObjSearch({ city: val, sgg: "" });
+ };
+
+ const getSgg = (val: string | number) => {
+ const sgg = form.getValues("sggCd");
+ setObjSearch({ ...objSearch, sgg: val != "" ? String(val) : sgg });
+ };
+
+ useEffect(() => {
+ const city = form.getValues("ctpvCd");
+ const sgg = form.getValues("sggCd");
+ setObjSearch({ city: city, sgg: sgg });
+ }, [selectSgg]);
+
+ useEffect(() => {
+ const subscription = form.form?.watch((value: any) => {
+ console.log("vale", value);
+ });
+
+ return () => subscription?.unsubscribe();
+ }, [form.form]);
+
+ const [selectedIds, setSelectedIds] = useState([]);
+
+ const toggleSelect = (id: string) => {
+ setSelectedIds(prev =>
+ prev.includes(id)
+ ? prev.filter(x => x !== id)
+ : [...prev, id]
+ );
+ };
+
+ return (
+ <>
+
+ 건축물 시설 정보
+
+
+
+ (
+
+ {
+ getSelCity(String(val));
+ field.onChange(Number(val));
+ }}
+ value={field.value}
+ />
+
+ )}
+ />
+
+
+ (
+
+ {
+ getSgg(val);
+ field.onChange(Number(val));
+ }}
+ value={field.value}
+ />
+
+ )}
+ />
+
+
+
+
+ (
+
+
+
+ )}
+ />
+
+
+ (
+
+
+
+ )}
+ />
+
+
+ (
+
+ {
+ field.onChange(Number(val));
+ }}
+ value={field.value}
+ />
+
+ )}
+ />
+
+
+ (
+
+ field.onChange(date),
+ }}
+ selectClass={'w-full'}
+ >
+
+ )}
+ />
+
+
+ (
+
+ {
+ handleCommaNumberChange(e, field.onChange);
+ }}
+ value={formatCommaNumber(field.value)}
+ />
+
+ )}
+ />
+
+
+ (
+
+ {
+ field.onChange(val);
+ }}
+ value={field.value}
+ />
+
+ )}
+ />
+
+
+
+ 중축, 개축, 재축
+
+
+
+
+
+
+ {fields.map((field, index) => (
+
+
+ toggleSelect(field.id)}
+ />
+
+
+ (
+
+ f.onChange(val)}
+ value={f.value ?? code.chBuCd[0]?.val} className={""} label={""} />
+
+ )}
+ />
+
+
+ (
+
+ f.onChange(date),
+ }}
+ selectClass="w-full"
+ />
+
+ )}
+ />
+
+
+ (
+
+ handleCommaNumberChange(e, f.onChange)}
+ value={formatCommaNumber(f.value)}
+ className={selectClass}
+ />
+
+ )}
+ />
+
+
+ ))}
+
+ >
+ );
+}
diff --git a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx
new file mode 100644
index 000000000..70e62eb7f
--- /dev/null
+++ b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx
@@ -0,0 +1,634 @@
+"use client";
+
+import {
+ Form,
+ FormField,
+ FormUi,
+ SelectBox,
+} from "@common/business_components/ui";
+import { Button, Input } from "@common/components/ui";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { useForm } from "react-hook-form";
+import { z } from "zod";
+import { useWrStore } from "@/app/store";
+import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
+import {
+ hdtflZod,
+ type customHtdflBdst,
+} from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
+import { useEffect } from "react";
+import BdstReg from "../bdstReg/bdstReg";
+import {
+ formatCommaNumber,
+ handleCommaNumberChange,
+} from "@/components/lib/func/commom";
+import { formH1Class } from "@/components/lib/class/comClass";
+
+export default function HtdflRegForm({
+ htdflForm,
+ isModal,
+ readonly = false
+}: {
+ htdflForm: customHtdflBdst;
+ isModal: boolean;
+ readonly?: boolean;
+}) {
+ const { code, htdflBdstUpdate, htdflBdstReg } = useWrStore((state) => state);
+
+ const defaultValues: z.infer = hdtflZod.parse({});
+
+ const form = useForm>({
+ resolver: zodResolver(hdtflZod),
+ defaultValues: defaultValues,
+ });
+
+ const onSubmit = (values: z.infer) => {
+ if (isModal) {
+ htdflBdstReg(values, '41');
+ } else {
+ htdflBdstUpdate(values, '41');
+ }
+ };
+
+
+ const cleanHtdflData = (raw: any): z.infer => {
+ return {
+ ...raw,
+ frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt || null),
+ archChgPrmsnDt: raw?.archChgPrmsnDt
+ ? new Date(raw?.archChgPrmsnDt)
+ : null,
+ chgBuilding: (raw?.chgBuilding || []).map((item: any) => ({
+ ...item,
+ archChgPrmsnDt:
+ item?.archChgPrmsnDt === null
+ ? new Date()
+ : new Date(item?.archChgPrmsnDt),
+ bdstChgNm: item?.bdstChgNm ?? "", // null → ""
+ })),
+ reuseBuilding: (raw?.reuseBuilding || []).map((item: any) => ({
+ ...item,
+ instlCmptnDt: new Date(item?.instlCmptnDt),
+ htdflObj: {
+ ...item?.htdflObj,
+ },
+ })),
+ };
+ };
+
+ useEffect(() => {
+ console.log("form errors:", form.formState.errors);
+ }, [form.formState.errors]);
+
+ useEffect(() => {
+ if (hdtflZod) form.reset(cleanHtdflData(htdflForm));
+ }, [htdflForm]);
+
+ return (
+