diff --git a/apps/dm/.env.development b/apps/dm/.env.development new file mode 100644 index 000000000..622545fd6 --- /dev/null +++ b/apps/dm/.env.development @@ -0,0 +1,19 @@ +NEXT_PUBLIC_SITE_ID = DM +NEXT_PUBLIC_PORT = 3000 +NEXT_PUBLIC_PROXY_HOST = http://localhost:3000 +NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1 +NEXT_PUBLIC_FO_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1 +NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload +NEXT_PUBLIC_CLAIM_NAME = Authorization +NEXT_PUBLIC_AUTH_USER_ID = token-id +NEXT_PUBLIC_ACCESS_TOKEN = access-token +NEXT_PUBLIC_REFRESH_TOKEN = refresh-token + + + +NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API +# NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.128:8883/sewerage-service/api # 최용성 +#NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.66:8883/sewerage-service/api # 박이정 + + diff --git a/apps/dm/.env.local b/apps/dm/.env.local new file mode 100644 index 000000000..622545fd6 --- /dev/null +++ b/apps/dm/.env.local @@ -0,0 +1,19 @@ +NEXT_PUBLIC_SITE_ID = DM +NEXT_PUBLIC_PORT = 3000 +NEXT_PUBLIC_PROXY_HOST = http://localhost:3000 +NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1 +NEXT_PUBLIC_FO_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1 +NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload +NEXT_PUBLIC_CLAIM_NAME = Authorization +NEXT_PUBLIC_AUTH_USER_ID = token-id +NEXT_PUBLIC_ACCESS_TOKEN = access-token +NEXT_PUBLIC_REFRESH_TOKEN = refresh-token + + + +NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API +# NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.128:8883/sewerage-service/api # 최용성 +#NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.66:8883/sewerage-service/api # 박이정 + + diff --git a/apps/dm/.env.production b/apps/dm/.env.production new file mode 100644 index 000000000..8a552821e --- /dev/null +++ b/apps/dm/.env.production @@ -0,0 +1,17 @@ +NEXT_PUBLIC_SITE_ID = DM +NEXT_PUBLIC_PORT = 3000 +NEXT_PUBLIC_PROXY_HOST = http://wr.hasuon.or.kr +NEXT_PUBLIC_SERVER_API_URL = http://apigateway.iipbs-dev.svc.cluster.local:8000/api/v1 +NEXT_PUBLIC_FO_SERVER_API_URL = http://apigateway.iipbs-dev.svc.cluster.local:8000/operation-service/api/v1 +NEXT_PUBLIC_CS_SERVER_API_URL = http://apigateway.iipbs-dev.svc.cluster.local:8000 +NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload +NEXT_PUBLIC_GEOSERVER_URL = http://172.29.143.87:8080/geoserver +NEXT_PUBLIC_LX_GEOSERVER_URL = http://172.29.143.87:8080/geoserver_swl +NEXT_PUBLIC_CLAIM_NAME = Authorization +NEXT_PUBLIC_AUTH_USER_ID = token-id +NEXT_PUBLIC_ACCESS_TOKEN = access-token +NEXT_PUBLIC_REFRESH_TOKEN = refresh-token + +NEXT_PUBLIC_SEWERAGE_API_URL = http://apigateway.iipbs-dev.svc.cluster.local:8000/sewerage-service/api + + diff --git a/apps/dm/.gitignore b/apps/dm/.gitignore index 5ef6a5207..c1b3c4e38 100644 --- a/apps/dm/.gitignore +++ b/apps/dm/.gitignore @@ -1,7 +1,6 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules /.pnp .pnp.* .yarn/* @@ -31,7 +30,6 @@ yarn-error.log* .pnpm-debug.log* # env files (can opt-in for committing if needed) -.env* # vercel .vercel diff --git a/apps/dm/app/base.tsx b/apps/dm/app/base.tsx new file mode 100644 index 000000000..3905c9952 --- /dev/null +++ b/apps/dm/app/base.tsx @@ -0,0 +1,22 @@ +"use client"; + +import { BaseLayout } from "@common/components"; +import type { MenuItem } from "./store/common"; +import { useDmStore } from "./store"; +import { useRouter } from "next/navigation"; + +export default function Base({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + const { getMenuAuth } = useDmStore((state) => state); + + const router = useRouter(); + const handleClick = (id:MenuItem) =>{ + getMenuAuth(id.menuCd); + router.push(id.urlPath); + } + + return {children}; +} diff --git a/apps/dm/app/layout.tsx b/apps/dm/app/layout.tsx index 0aac0da38..7c0f47a30 100644 --- a/apps/dm/app/layout.tsx +++ b/apps/dm/app/layout.tsx @@ -1,6 +1,5 @@ -"use client"; - -import { BaseLayout } from "@common/components"; +"use client" +import Base from "./base"; import "./globals.css"; import { StoreProvider } from "./store"; @@ -13,11 +12,9 @@ export default function RootLayout({ - - {children} - + {children} ); -} +} \ No newline at end of file diff --git a/apps/dm/app/pages/sdmMng/sdmInfoInsert/modalSimilar/page.tsx b/apps/dm/app/pages/sdmMng/sdmInfoInsert/modalSimilar/page.tsx index 8da2685da..22418c7b7 100644 --- a/apps/dm/app/pages/sdmMng/sdmInfoInsert/modalSimilar/page.tsx +++ b/apps/dm/app/pages/sdmMng/sdmInfoInsert/modalSimilar/page.tsx @@ -52,7 +52,7 @@ export default function ModalSimilarPage({ sply = 0, usageCd = '', money = 0 }: return spans; }, [similarCaseList]); - const handleCellClick = (index: number, headId: string) => { + const handleCellClick = (index: number) => { setMoneyDetailList([{ reqBizGrssCst: similarCaseList[index]?.reqBizGrssCst ?? '', reqBizReuseFcltCst: similarCaseList[index]?.reqBizReuseFcltCst ?? '', @@ -124,10 +124,10 @@ export default function ModalSimilarPage({ sply = 0, usageCd = '', money = 0 }: key={`similar-case-cell-${head.id}-${index}-${el.ruseBizNm}`} rowSpan={(head.id === 'businessName' || head.id ==='businessDuration' || head.id === 'money') ? rowSpans[index] : undefined} style={(head.id === 'businessName' || head.id === 'businessDuration' || head.id === 'money') && index > 0 && similarCaseList[index - 1]?.ruseBizNm === el.ruseBizNm ? { display: 'none' } : undefined} - onClick={() => handleCellClick(index, head.id)} + onClick={() => handleCellClick(index)} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { - handleCellClick(index, head.id); + handleCellClick(index); } }} > diff --git a/apps/dm/app/pages/sdmMng/sdmInfoInsert/page.tsx b/apps/dm/app/pages/sdmMng/sdmInfoInsert/page.tsx index 119e1c487..a0f905c35 100644 --- a/apps/dm/app/pages/sdmMng/sdmInfoInsert/page.tsx +++ b/apps/dm/app/pages/sdmMng/sdmInfoInsert/page.tsx @@ -9,7 +9,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { useSearchParams } from "next/navigation"; import { Suspense, useEffect, useState } from "react"; import { FormProvider, useForm, type SubmitHandler } from "react-hook-form"; -import { Toaster, toast } from "react-hot-toast"; +import { Toaster } from "react-hot-toast"; import * as z from "zod"; import SdmLogin from "../sdmLogin/page"; diff --git a/apps/dm/app/pages/wrStatus/page.tsx b/apps/dm/app/pages/wrStatus/page.tsx index 4e830608f..dd7ec5552 100644 --- a/apps/dm/app/pages/wrStatus/page.tsx +++ b/apps/dm/app/pages/wrStatus/page.tsx @@ -1,8 +1,7 @@ 'use client'; -import React, { useState, useEffect, useRef } from 'react'; -import Image from 'next/image'; import { CHART_FORM, MainChart, type ChartConfig } from '@common/business_components'; +import React, { useEffect, useRef, useState } from 'react'; interface RegionData { name: string; @@ -22,12 +21,10 @@ interface TableData { const WrStatusPage: React.FC = () => { const [selectedRegion, setSelectedRegion] = useState(null); - const [originalFills, setOriginalFills] = useState>({}); const [hoveredRegion, setHoveredRegion] = useState(null); const [tooltipPosition, setTooltipPosition] = useState<{ x: number; y: number } | null>(null); - const [favorites, setFavorites] = useState>({}); const svgContainerRef = useRef(null); - const [chartData, setChartData] = useState([ + const [chartData] = useState([ { label : '서울', 하수 : 4, @@ -244,12 +241,6 @@ const WrStatusPage: React.FC = () => { } }; - const handleFavoriteClick = (region: string) => { - setFavorites(prev => ({ - ...prev, - [region]: !prev[region] - })); - }; const createDonutMarker = (svg: SVGSVGElement, x: number, y: number, name: string, values: number[]) => { const colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#FED16A']; @@ -395,13 +386,13 @@ const WrStatusPage: React.FC = () => { if (selectedRegion === pathId) { path.setAttribute('fill', '#2563eb'); } else { - const original = originalFills[pathId] || '#ffffff'; + const original = '#ffffff'; path.setAttribute('fill', original); } } }); } - }, [selectedRegion, originalFills]); + }, [selectedRegion]); return (
diff --git a/apps/dm/app/store/common/index.tsx b/apps/dm/app/store/common/index.tsx index c62ebdd0a..cf4ce14d8 100644 --- a/apps/dm/app/store/common/index.tsx +++ b/apps/dm/app/store/common/index.tsx @@ -14,6 +14,26 @@ export type SelectDataType = { val: string; } +export interface MenuItem { + menuCd: number; + menuKornNm: string; + menuEngNm: string; + parentId: number | null; + sortSeq: number; + iconNm?: string; + children: MenuItem[] | null; + levelNo: number; + urlPath: string; + menuLnkgTypeCd: string; + menuLnkgSn: number; + menuPath: string; + qrcd: string; + useYn: string; + otptYn: string; + newWndwYn: string; + requiredUrlPath: boolean; +} + // grid header export type TableUpperProps = { id: string; @@ -312,6 +332,7 @@ const fetchEnvPartData = async (): Promise => { ====================================*/ export type CommonAction = { initializeCommonData: () => Promise; + getMenuAuth: (menuCd:number) => Promise; } export type CommonType = { @@ -358,6 +379,24 @@ export const CommonState:CommonType = { export const CommonReducer:(set:any)=>CommonAction=(set: any) => { return { + getMenuAuth : async (menuCd : number) =>{ + const response = await getFetch( + "local", + `/cms-service/api/v1/menu-authrts/pageinfo/${menuCd}` + ); + set((state: CommonType) => { + return { + ...state, + auth: { + mngAuthrtYn: response[0].mngAuthrtYn, + inqAuthrtYn: response[0].mngAuthrtYn, + regAuthrtYn: response[0].mngAuthrtYn, + mdfcnAuthrtYn: response[0].mngAuthrtYn, + delAuthrtYn: response[0].mngAuthrtYn, + }, + }; + }); + }, // 시도 변경 이벤트 initializeCommonData: async () => { const promiseSet = await Promise.all([fetchSidoData(), fetchSigunData(), fetchRegionData(), fetchUnitWaterShedData(), fetchMiddleRegionData(), fetchEnvPartData()]); diff --git a/apps/dm/app/store/sdmMng/index.tsx b/apps/dm/app/store/sdmMng/index.tsx index a2475970b..e51c6b56a 100644 --- a/apps/dm/app/store/sdmMng/index.tsx +++ b/apps/dm/app/store/sdmMng/index.tsx @@ -253,8 +253,6 @@ export const upHeadSdmInfoStatus: TableUpperProps[] = [ ] // 수요정보 신청현황 데이터 -const sdmInfoStatusList : DemandCompType[] = [ -] /**==================================== * Store - Api diff --git a/apps/dm/components/ui/config/index.ts b/apps/dm/components/ui/config/index.ts index 8bf23935c..2ed4ef03d 100644 --- a/apps/dm/components/ui/config/index.ts +++ b/apps/dm/components/ui/config/index.ts @@ -1,13 +1,5 @@ -const LOCAL_PORT = "3000"; -const DEV_PORT = "11080"; -const DEV_PORT_FO = "11082"; +import { PROXY_HOST, SERVER_API_FO_URL, SERVER_API_WR_URL } from "@/src/shared/config/env"; -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_FO = `http://con.mind-one.co.kr:${DEV_PORT_FO}/api/v1`; -export const LOCAL_URL_FO = `http://192.168.1.129:${DEV_PORT_FO}/api/v1`; -export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_FO}/api/v1`; - -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 +export const LOCAL_URL = PROXY_HOST; +export const DEV_URL_FO = SERVER_API_FO_URL; +export const DEV_URL_WR = SERVER_API_WR_URL; diff --git a/apps/dm/components/ui/sdmInfoInsertForm/AccessibleFormField.tsx b/apps/dm/components/ui/sdmInfoInsertForm/AccessibleFormField.tsx index 0c32db414..d2dfc00cb 100644 --- a/apps/dm/components/ui/sdmInfoInsertForm/AccessibleFormField.tsx +++ b/apps/dm/components/ui/sdmInfoInsertForm/AccessibleFormField.tsx @@ -12,7 +12,6 @@ interface AccessibleFormFieldProps { } export function AccessibleFormField({ - field, label, required = false, error, diff --git a/apps/dm/eslint.config.mjs b/apps/dm/eslint.config.mjs index c85fb67c4..29e63f653 100644 --- a/apps/dm/eslint.config.mjs +++ b/apps/dm/eslint.config.mjs @@ -11,6 +11,10 @@ const compat = new FlatCompat({ const eslintConfig = [ ...compat.extends("next/core-web-vitals", "next/typescript"), + {rules:{ + // other rules.. + "@typescript-eslint/no-explicit-any": "off", + }}, ]; export default eslintConfig; diff --git a/apps/dm/middleware.ts b/apps/dm/middleware.ts index cb8365e4e..9d914de2d 100644 --- a/apps/dm/middleware.ts +++ b/apps/dm/middleware.ts @@ -1,10 +1,9 @@ import { NextRequest, NextResponse } from "next/server"; -import { CS_URL } from "./components/ui/config"; import { CLAIM_NAME, AUTH_USER_ID } from "./src/shared/config"; // const CLAIM_NAME = "Authorization"; // const AUTH_USER_ID = "token-id"; - const serverApiUrl = CS_URL; +const serverApiUrl = process.env.NEXT_PUBLIC_CS_SERVER_API_URL; const GEOSERVER_URL = process.env.NEXT_PUBLIC_GEOSERVER_URL || ""; const LX_GEOSERVER_URL = process.env.NEXT_PUBLIC_LX_GEOSERVER_URL || ""; const SEWERAGE_API_URL = process.env.NEXT_PUBLIC_SEWERAGE_API_URL || ""; diff --git a/apps/dm/next.config.ts b/apps/dm/next.config.ts index 4d171bc44..48fc8dacb 100644 --- a/apps/dm/next.config.ts +++ b/apps/dm/next.config.ts @@ -1,41 +1,33 @@ import type { NextConfig } from "next"; -import webpack from "webpack"; + +const subDomain = + process.env.NEXT_PUBLIC_SUB_DOMAIN || "http://localhost:3000"; const nextConfig: NextConfig = { output: "standalone", - eslint: { - ignoreDuringBuilds: true, - }, - webpack: (config) => { - config.plugins.push( - new webpack.DefinePlugin({ - "import.meta.env.VITE_PORT": JSON.stringify( - process.env.NEXT_PUBLIC_PORT - ), - "import.meta.env.VITE_PROXY_HOST": JSON.stringify( - process.env.NEXT_PUBLIC_PROXY_HOST - ), - "import.meta.env.VITE_SERVER_API_URL": JSON.stringify( - process.env.NEXT_PUBLIC_SERVER_API_URL - ), - "import.meta.env.VITE_SITE_ID": JSON.stringify(process.env.SITE_ID), - "import.meta.env.VITE_CLAIM_NAME": JSON.stringify( - process.env.NEXT_PUBLIC_CLAIM_NAME - ), - "import.meta.env.VITE_ACCESS_TOKEN": JSON.stringify( - process.env.NEXT_PUBLIC_ACCESS_TOKEN - ), - "import.meta.env.VITE_REFRESH_TOKEN": JSON.stringify( - process.env.NEXT_PUBLIC_REFRESH_TOKEN - ), - "import.meta.env.VITE_AUTH_USER_ID": JSON.stringify( - process.env.NEXT_PUBLIC_AUTH_USER_ID - ), - "process.env.SITE_ID": JSON.stringify(process.env.NEXT_PUBLIC_SITE_ID), - }) - ); - - return config; + async rewrites() { + return { + beforeFiles: [ + { + source: "/_next/static/:path*", + destination: `${subDomain}/_next/static/:path*`, + has: [ + { + type: "header", + key: "referer", + value: "(.*)/pst(.*)", + }, + ], + }, + ], + afterFiles: [ + { + source: "/pst/:path*", + destination: `${subDomain}/pst/:path*`, + }, + ], + fallback: [], + }; }, }; diff --git a/apps/dm/package.json b/apps/dm/package.json index 2c9fe587b..2fdff5dbc 100644 --- a/apps/dm/package.json +++ b/apps/dm/package.json @@ -9,11 +9,13 @@ "lint": "next lint" }, "dependencies": { + "@common/assets": "workspace:*", "@common/business_components": "workspace:*", "@common/components": "workspace:*", "@hookform/resolvers": "^4.1.3", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", + "js-cookie": "^3.0.5", "js-sha512": "^0.9.0", "lucide-react": "^0.474.0", "next": "15.1.7", diff --git a/apps/dm/src/entities/auth/api/login-service.ts b/apps/dm/src/entities/auth/api/login-service.ts index 3cd387507..614aadbf9 100644 --- a/apps/dm/src/entities/auth/api/login-service.ts +++ b/apps/dm/src/entities/auth/api/login-service.ts @@ -1,4 +1,3 @@ - import type { LoginService, ILogin } from "../model/login-interface"; import { tokenManager } from "../lib/token-manager"; import {PROXY_HOST, ACCESS_TOKEN, AUTH_USER_ID,SITE_ID, CLAIM_NAME, ENDPOINT, JWT_EXPIRATION_TIME } from "../../../shared/config"; diff --git a/apps/dm/src/shared/config/index.ts b/apps/dm/src/shared/config/index.ts index cd83447d5..3ac40ddb4 100644 --- a/apps/dm/src/shared/config/index.ts +++ b/apps/dm/src/shared/config/index.ts @@ -1,2 +1,2 @@ export * from "./api"; -export * from "./env"; +export * from "./env"; \ No newline at end of file diff --git a/apps/dm/src/shared/lib/cookie.ts b/apps/dm/src/shared/lib/cookie.ts index 4bc0fe142..48254bb18 100644 --- a/apps/dm/src/shared/lib/cookie.ts +++ b/apps/dm/src/shared/lib/cookie.ts @@ -1,4 +1,3 @@ - import Cookies from "js-cookie"; diff --git a/apps/dm/tsconfig.json b/apps/dm/tsconfig.json index d897e147f..493584782 100644 --- a/apps/dm/tsconfig.json +++ b/apps/dm/tsconfig.json @@ -2,6 +2,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "extends": "../../tsconfig.base.json", "compilerOptions": { + "noImplicitAny": false, "baseUrl": ".", "target": "ES2017", "lib": ["dom", "dom.iterable", "esnext"], diff --git a/apps/fo/.env.development b/apps/fo/.env.development index b270a2694..76fb868cd 100644 --- a/apps/fo/.env.development +++ b/apps/fo/.env.development @@ -1,7 +1,9 @@ NEXT_PUBLIC_SITE_ID = FO -NEXT_PUBLIC_PORT = 11300 -NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11300 -NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_PORT = 3000 +NEXT_PUBLIC_PROXY_HOST = http://localhost:3000 +NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1 +NEXT_PUBLIC_WR_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1 +NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000 NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver NEXT_PUBLIC_CLAIM_NAME = Authorization @@ -10,3 +12,5 @@ NEXT_PUBLIC_ACCESS_TOKEN = access-token NEXT_PUBLIC_REFRESH_TOKEN = refresh-token NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API + + diff --git a/apps/fo/.env.local b/apps/fo/.env.local index ccb832d70..76fb868cd 100644 --- a/apps/fo/.env.local +++ b/apps/fo/.env.local @@ -1,7 +1,9 @@ NEXT_PUBLIC_SITE_ID = FO NEXT_PUBLIC_PORT = 3000 NEXT_PUBLIC_PROXY_HOST = http://localhost:3000 -NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1 +NEXT_PUBLIC_WR_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1 +NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000 NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver NEXT_PUBLIC_CLAIM_NAME = Authorization @@ -10,4 +12,5 @@ NEXT_PUBLIC_ACCESS_TOKEN = access-token NEXT_PUBLIC_REFRESH_TOKEN = refresh-token NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API -#NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.128:8883/sewerage-service/api # 최용성 PC 서버 API + + diff --git a/apps/fo/.env.production b/apps/fo/.env.production index 15f2e7aea..16675eaec 100644 --- a/apps/fo/.env.production +++ b/apps/fo/.env.production @@ -1,12 +1,28 @@ +# NEXT_PUBLIC_SITE_ID = WR +# NEXT_PUBLIC_PORT = 11301 +# NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11301 +# NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000 +# NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver +# NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver +# NEXT_PUBLIC_CLAIM_NAME = Authorization +# NEXT_PUBLIC_AUTH_USER_ID = token-id +# NEXT_PUBLIC_ACCESS_TOKEN = access-token +# NEXT_PUBLIC_REFRESH_TOKEN = refresh-token + + + NEXT_PUBLIC_SITE_ID = FO -NEXT_PUBLIC_PORT = 3000 -NEXT_PUBLIC_PROXY_HOST = http://fo.hasuon.or.kr -NEXT_PUBLIC_SERVER_API_URL = http://apigateway.iipbs-dev.svc.cluster.local:8000 -NEXT_PUBLIC_GEOSERVER_URL = http://172.29.143.87:8080/geoserver -NEXT_PUBLIC_LX_GEOSERVER_URL = http://172.29.143.87:8080/geoserver_swl +NEXT_PUBLIC_PORT = 11300 +NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11300 +NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1 +NEXT_PUBLIC_WR_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1 +NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver +NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver NEXT_PUBLIC_CLAIM_NAME = Authorization NEXT_PUBLIC_AUTH_USER_ID = token-id NEXT_PUBLIC_ACCESS_TOKEN = access-token NEXT_PUBLIC_REFRESH_TOKEN = refresh-token +NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API + -NEXT_PUBLIC_SEWERAGE_API_URL= http://apigateway.iipbs-dev.svc.cluster.local:8000/sewerage-service/api diff --git a/apps/fo/app/base.tsx b/apps/fo/app/base.tsx new file mode 100644 index 000000000..7bdf4f3e0 --- /dev/null +++ b/apps/fo/app/base.tsx @@ -0,0 +1,22 @@ +"use client"; + +import { BaseLayout } from "@common/components"; +import type { MenuItem } from "./store/common"; +import { useFoStore } from "./store"; +import { useRouter } from "next/navigation"; + +export default function Base({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + const { getMenuAuth } = useFoStore((state) => state); + + const router = useRouter(); + const handleClick = (id:MenuItem) =>{ + getMenuAuth(id.menuCd); + router.push(id.urlPath); + } + + return {children}; +} diff --git a/apps/fo/app/components/api/config/env.ts b/apps/fo/app/components/api/config/env.ts index 22272ecd8..d419bfd1c 100644 --- a/apps/fo/app/components/api/config/env.ts +++ b/apps/fo/app/components/api/config/env.ts @@ -1,12 +1,5 @@ -const DEV_PORT_COMMON = "11081"; -const DEV_PORT_FO = "11082"; -const DEV_PORT_WR = "11080"; +import { PROXY_HOST, SERVER_API_URL, SERVER_API_WR_URL } from "@/src/shared/config/env"; -export const LOCAL_URL_COMMON = `http://192.168.1.129:${DEV_PORT_COMMON}/api/v1`; -export const DEV_URL_COMMON = `http://con.mind-one.co.kr:${DEV_PORT_COMMON}/api/v1`; - -export const LOCAL_URL_FO = `http://192.168.1.129:${DEV_PORT_FO}/api/v1`; -export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_FO}/api/v1`; - -export const LOCAL_URL_WR = `http://192.168.1.129:${DEV_PORT_WR}/api/v1`; -export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT_WR}/api/v1`; +export const DEV_URL_FO = SERVER_API_URL; +export const LOCAL_URL = PROXY_HOST; +export const DEV_URL_WR = SERVER_API_WR_URL; \ No newline at end of file diff --git a/apps/fo/app/components/api/index.ts b/apps/fo/app/components/api/index.ts index fe8e54bb6..3bba85af2 100644 --- a/apps/fo/app/components/api/index.ts +++ b/apps/fo/app/components/api/index.ts @@ -1,8 +1,8 @@ -import { DEV_URL_COMMON, DEV_URL_FO, DEV_URL_WR } from "./config/env"; +import { DEV_URL_FO, DEV_URL_WR, LOCAL_URL } from "./config/env"; export const getFetch = async (part : string, url: string) => { let reqUrl = ""; - reqUrl = part === "fo" ? DEV_URL_FO+url : part === "wr" ? DEV_URL_WR+url : DEV_URL_COMMON+url; + reqUrl = part === "fo" ? DEV_URL_FO+url : part === 'local' ? LOCAL_URL+url : DEV_URL_WR+url; const response = await fetch(reqUrl , { method: "GET", headers: { @@ -32,7 +32,7 @@ export const getFetchAreaList = async (url: string) => { export const postFetch = async (part : string, url: string, params: unknown) => { let reqUrl = ""; - reqUrl = part === "fo" ? DEV_URL_FO+url : DEV_URL_COMMON+url; + reqUrl = part === "fo" ? DEV_URL_FO+url : DEV_URL_WR+url; const response = await fetch(reqUrl, { method: "POST", headers: { @@ -48,7 +48,7 @@ export const postFetch = async (part : string, url: string, params: unknown) => export const putFetch = async (part : string, url: string, params: unknown) => { let reqUrl = ""; - reqUrl = part === "fo" ? DEV_URL_FO+url : DEV_URL_COMMON+url; + reqUrl = part === "fo" ? DEV_URL_FO+url : DEV_URL_WR+url; const response = await fetch(reqUrl, { method: "PUT", headers: { @@ -64,7 +64,7 @@ export const putFetch = async (part : string, url: string, params: unknown) => { export const deleteFetch = async (part : string, url: string, params: unknown) => { let reqUrl = ""; - reqUrl = part === "fo" ? DEV_URL_FO+url : DEV_URL_COMMON+url; + reqUrl = part === "fo" ? DEV_URL_FO+url : DEV_URL_WR+url; const response = await fetch(reqUrl, { method: "DELETE", headers: { diff --git a/apps/fo/app/layout.tsx b/apps/fo/app/layout.tsx index 548ef77a9..352c25034 100644 --- a/apps/fo/app/layout.tsx +++ b/apps/fo/app/layout.tsx @@ -1,10 +1,8 @@ "use client" -import { BaseLayout } from "@common/components/ui"; +import Base from "./base"; import "./globals.css"; import { StoreProvider } from "./store"; - - export default function RootLayout({ children, }: Readonly<{ @@ -14,9 +12,7 @@ export default function RootLayout({ - - {children} - + {children} diff --git a/apps/fo/app/pages/dashboardMain/page.tsx b/apps/fo/app/pages/dashboardMain/page.tsx index 3fa403d90..ccbf42c9d 100644 --- a/apps/fo/app/pages/dashboardMain/page.tsx +++ b/apps/fo/app/pages/dashboardMain/page.tsx @@ -51,8 +51,8 @@ export default function DashBoardFclty({ onFacilityChange, sidoSigun, facilityNm console.log('bscFctNm : ', bscFctNm); return ( - <> +
- +
); } \ No newline at end of file diff --git a/apps/fo/app/store/common/index.tsx b/apps/fo/app/store/common/index.tsx index ceba9b651..5c07bcd6e 100644 --- a/apps/fo/app/store/common/index.tsx +++ b/apps/fo/app/store/common/index.tsx @@ -3,6 +3,8 @@ ====================================**/ import { getFetch } from "@/app/components/api"; +import { LoginApi } from "@/src/entities/auth"; +import type { ILogin } from "@/src/entities/auth/model/login-interface"; /** * STORE - TYPE @@ -63,6 +65,26 @@ export type envPartSelectDataType = SelectDataType & { adstDliStrCd: string, } +export interface MenuItem { + menuCd: number; + menuKornNm: string; + menuEngNm: string; + parentId: number | null; + sortSeq: number; + iconNm?: string; + children: MenuItem[] | null; + levelNo: number; + urlPath: string; + menuLnkgTypeCd: string; + menuLnkgSn: number; + menuPath: string; + qrcd: string; + useYn: string; + otptYn: string; + newWndwYn: string; + requiredUrlPath: boolean; +} + /** * STORE - DATA */ @@ -305,6 +327,7 @@ const fetchEnvPartData = async (): Promise => { * Store - expaort ====================================*/ export type CommonAction = { + getMenuAuth : (menuCd : number) => Promise; initializeCommonData: () => Promise; } @@ -326,10 +349,18 @@ export type CommonType = { selectFlowPanel: SelectDataType[]; selectEnvPartData: envPartSelectDataType[]; btnClass: string; - } -} + }; -export const commonState:CommonType = { + auth: { + mngAuthrtYn: string; + inqAuthrtYn: string; + regAuthrtYn: string; + mdfcnAuthrtYn: string; + delAuthrtYn: string; + }; +}; + +export const commonState: CommonType = { Common: { isInit: false, selectSidoData: selectSidoData, @@ -341,22 +372,60 @@ export const commonState:CommonType = { selectRegionData: selectRegionData, selectUnitWaterShedData: selectUnitWaterShedData, selectMiddleRegionData: selectMiddleRegionData, - selectEnvPartSidoData : selectEnvPartSidoData, - selectEnvPartSigunData : selectEnvPartSigunData, + selectEnvPartSidoData: selectEnvPartSidoData, + selectEnvPartSigunData: selectEnvPartSigunData, selectFlowTerm: selectFlowTerm, selectFlowPanel: selectFlowPanel, - selectEnvPartData : selectEnvPartData, - btnClass: "p-4 m-2 text-white rounded-sm text-lg font-medium" - } -} + selectEnvPartData: selectEnvPartData, + btnClass: "p-4 m-2 text-white rounded-sm text-lg font-medium", + }, + + auth: { + mngAuthrtYn: "N", + inqAuthrtYn: "N", + regAuthrtYn: "N", + mdfcnAuthrtYn: "N", + delAuthrtYn: "N", + }, +}; export const CommonReducer:(set:(fn: (state: CommonType) => CommonType) => void)=>CommonAction=(set: (fn: (state: CommonType) => CommonType) => void) => { return { + // 메뉴 권한 확인 + getMenuAuth : async (menuCd : number) =>{ + const response = await getFetch( + "local", + `/cms-service/api/v1/menu-authrts/pageinfo/${menuCd}` + ); + set((state: CommonType) => { + return { + ...state, + auth: { + mngAuthrtYn: response[0].mngAuthrtYn, + inqAuthrtYn: response[0].mngAuthrtYn, + regAuthrtYn: response[0].mngAuthrtYn, + mdfcnAuthrtYn: response[0].mngAuthrtYn, + delAuthrtYn: response[0].mngAuthrtYn, + }, + }; + }); + }, + // 시도 변경 이벤트 initializeCommonData: async () => { + const payLoad : ILogin = { + userId: "tuser10003", + password: "test1234!" + }; + + console.log(payLoad.userId) + console.log(payLoad.password) + + LoginApi.login(payLoad); const promiseSet = await Promise.all([fetchSidoData(), fetchSigunData(), fetchRegionData(), fetchUnitWaterShedData(), fetchMiddleRegionData(), fetchEnvPartData()]); const [sidoData, sggData, regionData, unitData, midData, envData] = promiseSet; set((state: CommonType) => ({ + ...state, Common: { ...state.Common, selectSidoData: sidoData, @@ -371,4 +440,4 @@ export const CommonReducer:(set:(fn: (state: CommonType) => CommonType) => void) } } -export type CommonStore = CommonType & CommonAction; +export type CommonStore = CommonType & CommonAction; \ No newline at end of file diff --git a/apps/fo/app/store/dashboard/index.tsx b/apps/fo/app/store/dashboard/index.tsx index 8b04da6ff..09c7acec9 100644 --- a/apps/fo/app/store/dashboard/index.tsx +++ b/apps/fo/app/store/dashboard/index.tsx @@ -356,7 +356,7 @@ const upHeadListRainManage : TableUpperProps[] = [ { id: "A", title: "유입(㎥/일)", row:0, colSpan:2 }, { id: "inflAmnt", title: "유입유량", row:1 }, { id: "fctCpc", title: "시설용량대비", row:1 }, - { id: "B", title: "설계유입수질(㎎/L)", row:0, colSpan:5 }, + { id: "B", title: "설계유입수질(㎎/L)", row:0, colSpan:5 }, { id: "dsInflWqltBod", title: "BOD", row:1 }, { id: "dsInflWqltCod", title: "TOC\n(COD)", row:1 }, { id: "dsInflWqltSs", title: "SS", row:1 }, @@ -896,6 +896,49 @@ export const dataFormSetting=(item : OperationalStatusListProps)=> { DataForm({ type: 'float2', column: 'rainRate', item: item as unknown as Record}); }; +const changeValue=(operationalStatus, data, keyTxt = 'INFL_AMNT')=>{ + operationalStatus.yearAvg = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['AVG_'+keyTxt] : ''; + operationalStatus.yearMax = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['MAX_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['MAX_'+keyTxt] : ''; + operationalStatus.yearMin = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['MIN_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['MIN_'+keyTxt] : ''; + // 여름 + operationalStatus.summerAll = data.summer ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summer?Number(Math.round(data.summer['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summer['AVG_'+keyTxt] : ''; + operationalStatus.summerThree = data.summerRainy ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summerRainy?Number(Math.round(data.summerRainy["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summerRainy["AVG_" + keyTxt] : ''; + operationalStatus.summerRain = data.summerSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summerSunny?Number(Math.round(data.summerSunny["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summerSunny["AVG_" + keyTxt] : ''; + // 겨울 + operationalStatus.winterAll = data.winter ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winter?Number(Math.round(data.winter["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winter["AVG_" + keyTxt] : ''; + operationalStatus.winterSunnyMin = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["MIN_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["MIN_" + keyTxt] : ''; + operationalStatus.winterSunnyAvg = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["AVG_" + keyTxt] : ''; + operationalStatus.winterSunnyMax = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["MAX_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["MAX_" + keyTxt] : ''; + // 지하수 + operationalStatus.groundWaterAvg = 10; + operationalStatus.groundWaterSummer = 11; + operationalStatus.groundWaterWinter = 12; + // 오염물질 + // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) + const summerLowFlow = data.summerBod && data.summerBod.INFL_AMNT && data.summerBod.INFL_AMNT != 'null' ? Number(data.summerBod.INFL_AMNT) : 0; + const winterAvgBod = data.winterSunny && data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD && data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD != 'null' ? Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD) : 0; + const summerLowBod = data.summerBod && data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD && data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD != 'null' ? Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD) : 0; + const summerLowRain = data.summerBod && data.summerBod.INFO_RN_DAY && data.summerBod.INFO_RN_DAY != 'null' ? Number(data.summerBod.INFO_RN_DAY) : 0; + operationalStatus.rdi = winterAvgBod === 0 ? 0 : summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); + operationalStatus.rdiRain = summerLowRain; +} + +const calcValue = (operationalStatus, data, keyTxt='INFL_ASSCT_BFR_WQLT_TP') => { + // 연간 + operationalStatus.yearAvg = data.yearData ? Number(Math.round(data.yearData['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString() : ''; + operationalStatus.yearMax = data.yearData ? Number(Math.round(data.yearData.MAX_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + operationalStatus.yearMin = data.yearData ? Number(Math.round(data.yearData.MIN_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + // 여름 + operationalStatus.summerAll = data.summer ? Number(Math.round(data.summer.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + operationalStatus.summerThree = data.summerRainy ? Number(Math.round(data.summerRainy.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + operationalStatus.summerRain = data.summerSunny ? Number(Math.round(data.summerSunny.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + // 겨울 + operationalStatus.winterAll = data.winter ? Number(Math.round(data.winter.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + operationalStatus.winterSunnyMin = data.winterSunny ? Number(Math.round(data.winterSunny.MIN_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + operationalStatus.winterSunnyAvg = data.winterSunny ? Number(Math.round(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; + operationalStatus.winterSunnyMax = data.winterSunny ? Number(Math.round(data.winterSunny.MAX_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString() : ''; +} + export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType) => void)=>DashBoardActions=(set: (fn: (state: DashBoardType) => DashBoardType) => void) => { return { initializeDashBoardData: async () => { @@ -969,18 +1012,33 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType) // 유량 - 유입 if (operationalStatusList?.[0]) { // 연간 - operationalStatusList[0].yearAvg = data.yearData===null?'':data.yearData.AVG_INFL_AMNT?data.yearData.AVG_INFL_AMNT:0+data.yearData.AVG_SUM_FLOW?data.yearData.AVG_SUM_FLOW:0+data.yearData.AVG_TP_INFL_WQLT_TP?data.yearData.AVG_TP_INFL_WQLT_TP:0; - operationalStatusList[0].yearMax = data.yearData===null?'':data.yearData.MAX_INFL_AMNT?data.yearData.MAX_INFL_AMNT:0+data.yearData.MAX_SUM_FLOW?data.yearData.MAX_SUM_FLOW:0+data.yearData.MAX_TP_INFL_WQLT_TP?data.yearData.MAX_TP_INFL_WQLT_TP:0; - operationalStatusList[0].yearMin = data.yearData===null?'':data.yearData.MIN_INFL_AMNT?data.yearData.MIN_INFL_AMNT:0+data.yearData.MIN_SUM_FLOW?data.yearData.MIN_SUM_FLOW:0+data.yearData.MIN_TP_INFL_WQLT_TP?data.yearData.MIN_TP_INFL_WQLT_TP:0; + const yearAvg = data.yearData===null?'':(data.yearData.AVG_INFL_AMNT?data.yearData.AVG_INFL_AMNT:0)+(data.yearData.AVG_SUM_FLOW?data.yearData.AVG_SUM_FLOW:0)+(data.yearData.AVG_RETURN_AMNT?data.yearData.AVG_RETURN_AMNT:0); + const yearMax = data.yearData===null?'':(data.yearData.MAX_INFL_AMNT?data.yearData.MAX_INFL_AMNT:0)+(data.yearData.MAX_SUM_FLOW?data.yearData.MAX_SUM_FLOW:0)+(data.yearData.MAX_RETURN_AMNT?data.yearData.MAX_RETURN_AMNT:0); + const yearMin = data.yearData===null?'':(data.yearData.MIN_INFL_AMNT?data.yearData.MIN_INFL_AMNT:0)+(data.yearData.MIN_SUM_FLOW?data.yearData.MIN_SUM_FLOW:0)+(data.yearData.MIN_RETURN_AMNT?data.yearData.MIN_RETURN_AMNT:0); + operationalStatusList[0].yearAvg = yearAvg; + operationalStatusList[0].yearMax = yearMax; + operationalStatusList[0].yearMin = yearMin; // 여름 - operationalStatusList[0].summerAll = data.summer===null?'':data.summer.AVG_INFL_AMNT?data.summer.AVG_INFL_AMNT:0+data.summer.AVG_SUM_FLOW?data.summer.AVG_SUM_FLOW:0+data.summer.AVG_TP_INFL_WQLT_TP?data.summer.AVG_TP_INFL_WQLT_TP:0; - operationalStatusList[0].summerThree = data.summerRainy===null?'':data.summerRainy.AVG_INFL_AMNT?data.summerRainy.AVG_INFL_AMNT:0+data.summerRainy.AVG_SUM_FLOW?data.summerRainy.AVG_SUM_FLOW:0+data.summerRainy.AVG_TP_INFL_WQLT_TP?data.summerRainy.AVG_TP_INFL_WQLT_TP:0; - operationalStatusList[0].summerRain = data.summerSunny===null?'':data.summerSunny.AVG_INFL_AMNT?data.summerSunny.AVG_INFL_AMNT:0+data.summerSunny.AVG_SUM_FLOW?data.summerSunny.AVG_SUM_FLOW:0+data.summerSunny.AVG_TP_INFL_WQLT_TP?data.summerSunny.AVG_TP_INFL_WQLT_TP:0; + operationalStatusList[0].summerAll = data.summer === null ? '' : ( + (data.summer.AVG_INFL_AMNT ? data.summer.AVG_INFL_AMNT : 0) + + (data.summer.AVG_SUM_FLOW ? data.summer.AVG_SUM_FLOW : 0) + + (data.summer.AVG_TP_INFL_WQLT_TP ? data.summer.AVG_TP_INFL_WQLT_TP : 0) + ); + operationalStatusList[0].summerThree = data.summerRainy === null ? '' : ( + (data.summerRainy.AVG_INFL_AMNT ? data.summerRainy.AVG_INFL_AMNT : 0) + + (data.summerRainy.AVG_SUM_FLOW ? data.summerRainy.AVG_SUM_FLOW : 0) + + (data.summerRainy.AVG_TP_INFL_WQLT_TP ? data.summerRainy.AVG_TP_INFL_WQLT_TP : 0) + ); + operationalStatusList[0].summerRain = data.summerSunny === null ? '' : ( + (data.summerSunny.AVG_INFL_AMNT ? data.summerSunny.AVG_INFL_AMNT : 0) + + (data.summerSunny.AVG_SUM_FLOW ? data.summerSunny.AVG_SUM_FLOW : 0) + + (data.summerSunny.AVG_TP_INFL_WQLT_TP ? data.summerSunny.AVG_TP_INFL_WQLT_TP : 0) + ); // 겨울 - operationalStatusList[0].winterAll = data.winter===null?'':data.winter.AVG_INFL_AMNT?data.winter.AVG_INFL_AMNT:0+data.winter.AVG_SUM_FLOW?data.winter.AVG_SUM_FLOW:0+data.winter.AVG_TP_INFL_WQLT_TP?data.winter.AVG_TP_INFL_WQLT_TP:0; - operationalStatusList[0].winterSunnyMin = data.winterSunny===null?'':data.winterSunny.MIN_INFL_AMNT?data.winterSunny.MIN_INFL_AMNT:0+data.winterSunny.MIN_SUM_FLOW?data.winterSunny.MIN_SUM_FLOW:0+data.winterSunny.MIN_TP_INFL_WQLT_TP?data.winterSunny.MIN_TP_INFL_WQLT_TP:0; - operationalStatusList[0].winterSunnyAvg = data.winterSunny===null?'':data.winterSunny.AVG_INFL_AMNT?data.winterSunny.AVG_INFL_AMNT:0+data.winterSunny.AVG_SUM_FLOW?data.winterSunny.AVG_SUM_FLOW:0+data.winterSunny.AVG_TP_INFL_WQLT_TP?data.winterSunny.AVG_TP_INFL_WQLT_TP:0; - operationalStatusList[0].winterSunnyMax = data.winterSunny===null?'':data.winterSunny.MAX_INFL_AMNT?data.winterSunny.MAX_INFL_AMNT:0+data.winterSunny.MAX_SUM_FLOW?data.winterSunny.MAX_SUM_FLOW:0+data.winterSunny.MAX_TP_INFL_WQLT_TP?data.winterSunny.MAX_TP_INFL_WQLT_TP:0; + operationalStatusList[0].winterAll = data.winter === null ? '' : (data.winter.AVG_INFL_AMNT ? data.winter.AVG_INFL_AMNT : 0) + (data.winter.AVG_SUM_FLOW ? data.winter.AVG_SUM_FLOW : 0) + (data.winter.AVG_TP_INFL_WQLT_TP ? data.winter.AVG_TP_INFL_WQLT_TP : 0); + operationalStatusList[0].winterSunnyMin = data.winterSunny === null ? '' : (data.winterSunny.MIN_INFL_AMNT ? data.winterSunny.MIN_INFL_AMNT : 0) + (data.winterSunny.MIN_SUM_FLOW ? data.winterSunny.MIN_SUM_FLOW : 0) + (data.winterSunny.MIN_TP_INFL_WQLT_TP ? data.winterSunny.MIN_TP_INFL_WQLT_TP : 0); + operationalStatusList[0].winterSunnyAvg = data.winterSunny === null ? '' : (data.winterSunny.AVG_INFL_AMNT ? data.winterSunny.AVG_INFL_AMNT : 0) + (data.winterSunny.AVG_SUM_FLOW ? data.winterSunny.AVG_SUM_FLOW : 0) + (data.winterSunny.AVG_TP_INFL_WQLT_TP ? data.winterSunny.AVG_TP_INFL_WQLT_TP : 0); + operationalStatusList[0].winterSunnyMax = data.winterSunny === null ? '' : (data.winterSunny.MAX_INFL_AMNT ? data.winterSunny.MAX_INFL_AMNT : 0) + (data.winterSunny.MAX_SUM_FLOW ? data.winterSunny.MAX_SUM_FLOW : 0) + (data.winterSunny.MAX_TP_INFL_WQLT_TP ? data.winterSunny.MAX_TP_INFL_WQLT_TP : 0); // 지하수 operationalStatusList[0].groundWaterAvg = 10; operationalStatusList[0].groundWaterSummer = 11; @@ -996,280 +1054,16 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType) dataFormSetting(operationalStatusList[0]); } - // 유량 - 순수하수 - if (operationalStatusList?.[1]) { - // 연간 - operationalStatusList[1].yearAvg = data.yearData?data.yearData.AVG_INFL_AMNT:''; - operationalStatusList[1].yearMax = data.yearData?data.yearData.MAX_INFL_AMNT:''; - operationalStatusList[1].yearMin = data.yearData?data.yearData.MIN_INFL_AMNT:''; - // 여름 - operationalStatusList[1].summerAll = data.summer?data.summer.AVG_INFL_AMNT:''; - operationalStatusList[1].summerThree = data.summerRainy?data.summerRainy.AVG_INFL_AMNT:''; - operationalStatusList[1].summerRain = data.summerSunny?data.summerSunny.AVG_INFL_AMNT:''; - // 겨울 - operationalStatusList[1].winterAll = data.winter?data.winter.AVG_INFL_AMNT:''; - operationalStatusList[1].winterSunnyMin = data.winterSunny?data.winterSunny.MIN_INFL_AMNT:''; - operationalStatusList[1].winterSunnyAvg = data.winterSunny?data.winterSunny.AVG_INFL_AMNT:''; - operationalStatusList[1].winterSunnyMax = data.winterSunny?data.winterSunny.MAX_INFL_AMNT:''; - // 지하수 - operationalStatusList[1].groundWaterAvg = 10; - operationalStatusList[1].groundWaterSummer = 11; - operationalStatusList[1].groundWaterWinter = 12; - // 오염물질 - // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) - const summerLowFlow = data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0; - const winterAvgBod = data.winterSunny&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowBod = data.summerBod&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowRain = data.summerBod&&data.summerBod.INFO_RN_DAY&&data.summerBod.INFO_RN_DAY!='null'?Number(data.summerBod.INFO_RN_DAY):0; - operationalStatusList[1].rdi = winterAvgBod===0?0:summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); - operationalStatusList[1].rdiRain = summerLowRain; - dataFormSetting(operationalStatusList[1]); - } - - // 유량 - 연계처리수 - if (operationalStatusList?.[2]) { - // 연간 - operationalStatusList[2].yearAvg = data.yearData?data.yearData.AVG_SUM_FLOW:''; - operationalStatusList[2].yearMax = data.yearData?data.yearData.MAX_SUM_FLOW:''; - operationalStatusList[2].yearMin = data.yearData?data.yearData.MIN_SUM_FLOW:''; - // 여름 - operationalStatusList[2].summerAll = data.summer?data.summer.AVG_SUM_FLOW:''; - operationalStatusList[2].summerThree = data.summerRainy?data.summerRainy.AVG_SUM_FLOW:''; - operationalStatusList[2].summerRain = data.summerSunny?data.summerSunny.AVG_SUM_FLOW:''; - // 겨울 - operationalStatusList[2].winterAll = data.winter?data.winter.AVG_SUM_FLOW:''; - operationalStatusList[2].winterSunnyMin = data.winterSunny?data.winterSunny.MIN_SUM_FLOW:''; - operationalStatusList[2].winterSunnyAvg = data.winterSunny?data.winterSunny.AVG_SUM_FLOW:''; - operationalStatusList[2].winterSunnyMax = data.winterSunny?data.winterSunny.MAX_SUM_FLOW:''; - // 지하수 - operationalStatusList[2].groundWaterAvg = 10; - operationalStatusList[2].groundWaterSummer = 11; - operationalStatusList[2].groundWaterWinter = 12; - // 오염물질 - // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) - const summerLowFlow = data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0; - const winterAvgBod = data.winterSunny&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowBod = data.summerBod&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowRain = data.summerBod&&data.summerBod.INFO_RN_DAY&&data.summerBod.INFO_RN_DAY!='null'?Number(data.summerBod.INFO_RN_DAY):0; - operationalStatusList[2].rdi = winterAvgBod===0?0:summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); - operationalStatusList[2].rdiRain = summerLowRain; - dataFormSetting(operationalStatusList[2]); - } - - // 유량 - 총인설비방류수 - if (operationalStatusList?.[3]) { - // 연간 - operationalStatusList[3].yearAvg = data.yearData?data.yearData.AVG_TP_INFL_WQLT_TP:''; - operationalStatusList[3].yearMax = data.yearData?data.yearData.MAX_TP_INFL_WQLT_TP:''; - operationalStatusList[3].yearMin = data.yearData?data.yearData.MIN_TP_INFL_WQLT_TP:''; - // 여름 - operationalStatusList[3].summerAll = data.summer?data.summer.AVG_TP_INFL_WQLT_TP:''; - operationalStatusList[3].summerThree = data.summerRainy?data.summerRainy.AVG_TP_INFL_WQLT_TP:''; - operationalStatusList[3].summerRain = data.summerSunny?data.summerSunny.AVG_TP_INFL_WQLT_TP:''; - // 겨울 - operationalStatusList[3].winterAll = data.winter?data.winter.AVG_TP_INFL_WQLT_TP:''; - operationalStatusList[3].winterSunnyMin = data.winterSunny?data.winterSunny.MIN_TP_INFL_WQLT_TP:''; - operationalStatusList[3].winterSunnyAvg = data.winterSunny?data.winterSunny.AVG_TP_INFL_WQLT_TP:''; - operationalStatusList[3].winterSunnyMax = data.winterSunny?data.winterSunny.MAX_TP_INFL_WQLT_TP:''; - // 지하수 - operationalStatusList[3].groundWaterAvg = 10; - operationalStatusList[3].groundWaterSummer = 11; - operationalStatusList[3].groundWaterWinter = 12; - // 오염물질 - // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) - const summerLowFlow = data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0; - const winterAvgBod = data.winterSunny&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowBod = data.summerBod&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowRain = data.summerBod&&data.summerBod.INFO_RN_DAY&&data.summerBod.INFO_RN_DAY!='null'?Number(data.summerBod.INFO_RN_DAY):0; - operationalStatusList[3].rdi = winterAvgBod===0?0:summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); - operationalStatusList[3].rdiRain = summerLowRain; - dataFormSetting(operationalStatusList[3]); - } - - // 유량 - 방류수 - if (operationalStatusList?.[4]) { - // 연간 - operationalStatusList[4].yearAvg = data.yearData?data.yearData.AVG_EFFL_AMNT:''; - operationalStatusList[4].yearMax = data.yearData?data.yearData.MAX_EFFL_AMNT:''; - operationalStatusList[4].yearMin = data.yearData?data.yearData.MIN_EFFL_AMNT:''; - // 여름 - operationalStatusList[4].summerAll = data.summer?data.summer.AVG_EFFL_AMNT:''; - operationalStatusList[4].summerThree = data.summerRainy?data.summerRainy.AVG_EFFL_AMNT:''; - operationalStatusList[4].summerRain = data.summerSunny?data.summerSunny.AVG_EFFL_AMNT:''; - // 겨울 - operationalStatusList[4].winterAll = data.winter?data.winter.AVG_EFFL_AMNT:''; - operationalStatusList[4].winterSunnyMin = data.winterSunny?data.winterSunny.MIN_EFFL_AMNT:''; - operationalStatusList[4].winterSunnyAvg = data.winterSunny?data.winterSunny.AVG_EFFL_AMNT:''; - operationalStatusList[4].winterSunnyMax = data.winterSunny?data.winterSunny.MAX_EFFL_AMNT:''; - // 지하수 - operationalStatusList[4].groundWaterAvg = 10; - operationalStatusList[4].groundWaterSummer = 11; - operationalStatusList[4].groundWaterWinter = 12; - // 오염물질 - // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) - const summerLowFlow = data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0; - const winterAvgBod = data.winterSunny&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowBod = data.summerBod&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowRain = data.summerBod&&data.summerBod.INFO_RN_DAY&&data.summerBod.INFO_RN_DAY!='null'?Number(data.summerBod.INFO_RN_DAY):0; - operationalStatusList[4].rdi = winterAvgBod===0?0:summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); - operationalStatusList[4].rdiRain = summerLowRain; - dataFormSetting(operationalStatusList[4]); - } - - /* - * 수질 - 유입(BOD) - */ - if (operationalStatusList?.[5]) { - // 연간 - operationalStatusList[5].yearAvg = data.yearData?data.yearData.AVG_INFL_ASSCT_BFR_WQLT_BOD:''; - operationalStatusList[5].yearMax = data.yearData?data.yearData.MAX_INFL_ASSCT_BFR_WQLT_BOD:''; - operationalStatusList[5].yearMin = data.yearData?data.yearData.MIN_INFL_ASSCT_BFR_WQLT_BOD:''; - dataFormSetting(operationalStatusList[5]); - // 여름 - operationalStatusList[5].summerAll = data.summer?data.summer.AVG_INFL_ASSCT_BFR_WQLT_BOD:''; - operationalStatusList[5].summerThree = data.summerRainy?data.summerRainy.AVG_INFL_ASSCT_BFR_WQLT_BOD:''; - operationalStatusList[5].summerRain = data.summerSunny?data.summerSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD:''; - // 겨울 - operationalStatusList[5].winterAll = data.winter?data.winter.AVG_INFL_ASSCT_BFR_WQLT_BOD:''; - operationalStatusList[5].winterSunnyMin = data.winterSunny?data.winterSunny.MIN_INFL_ASSCT_BFR_WQLT_BOD:''; - operationalStatusList[5].winterSunnyAvg = data.winterSunny?data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD:''; - operationalStatusList[5].winterSunnyMax = data.winterSunny?data.winterSunny.MAX_INFL_ASSCT_BFR_WQLT_BOD:''; - // 오염물질 - // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) - const summerLowFlow = data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0; - const winterAvgBod = data.winterSunny&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowBod = data.summerBod&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD):0; - const summerLowRain = data.summerBod&&data.summerBod.INFO_RN_DAY&&data.summerBod.INFO_RN_DAY!='null'?Number(data.summerBod.INFO_RN_DAY):0; - operationalStatusList[5].rdi = winterAvgBod===0?0:summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); - operationalStatusList[5].rdiRain = summerLowRain; - dataFormSetting(operationalStatusList[5]); - } - - /** - * 수질-방류(BOD) - */ - if (operationalStatusList?.[6]) { - // 연간 - operationalStatusList[6].yearAvg = data.yearData?data.yearData.AVG_EFFL_WQLT_BOD:''; - operationalStatusList[6].yearMax = data.yearData?data.yearData.MAX_EFFL_WQLT_BOD:''; - operationalStatusList[6].yearMin = data.yearData?data.yearData.MIN_EFFL_WQLT_BOD:''; - dataFormSetting(operationalStatusList[6]); - // 여름 - operationalStatusList[6].summerAll = data.summer?data.summer.AVG_EFFL_WQLT_BOD:''; - operationalStatusList[6].summerThree = data.summerRainy?data.summerRainy.AVG_EFFL_WQLT_BOD:''; - operationalStatusList[6].summerRain = data.summerSunny?data.summerSunny.AVG_EFFL_WQLT_BOD:''; - // 겨울 - operationalStatusList[6].winterAll = data.winter?data.winter.AVG_EFFL_WQLT_BOD:''; - operationalStatusList[6].winterSunnyMin = data.winterSunny?data.winterSunny.MIN_EFFL_WQLT_BOD:''; - operationalStatusList[6].winterSunnyAvg = data.winterSunny?data.winterSunny.AVG_EFFL_WQLT_BOD:''; - operationalStatusList[6].winterSunnyMax = data.winterSunny?data.winterSunny.MAX_EFFL_WQLT_BOD:''; - dataFormSetting(operationalStatusList[6]); - } - - // 수질-유입(T-N) - if (operationalStatusList?.[7]) { - // 연간 - operationalStatusList[7].yearAvg = data.yearData?Number(Math.round(data.yearData.AVG_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[7].yearMax = data.yearData?Number(Math.round(data.yearData.MAX_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[7].yearMin = data.yearData?Number(Math.round(data.yearData.MIN_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - // 여름 - operationalStatusList[7].summerAll = data.summer?Number(Math.round(data.summer.AVG_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[7].summerThree = data.summerRainy?Number(Math.round(data.summerRainy.AVG_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[7].summerRain = data.summerSunny?Number(Math.round(data.summerSunny.AVG_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - // 겨울 - operationalStatusList[7].winterAll = data.winter?Number(Math.round(data.winter.AVG_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[7].winterSunnyMin = data.winterSunny?Number(Math.round(data.winterSunny.MIN_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[7].winterSunnyAvg = data.winterSunny?Number(Math.round(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[7].winterSunnyMax = data.winterSunny?Number(Math.round(data.winterSunny.MAX_INFL_ASSCT_BFR_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - } - - // 수질-방류(T-N) - if (operationalStatusList?.[8]) { - // 연간 - operationalStatusList[8].yearAvg = data.yearData?Number(Math.round(data.yearData.AVG_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[8].yearMax = data.yearData?Number(Math.round(data.yearData.MAX_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[8].yearMin = data.yearData?Number(Math.round(data.yearData.MIN_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - // 여름 - operationalStatusList[8].summerAll = data.summer?Number(Math.round(data.summer.AVG_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[8].summerThree = data.summerRainy?Number(Math.round(data.summerRainy.AVG_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[8].summerRain = data.summerSunny?Number(Math.round(data.summerSunny.AVG_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - // 겨울 - operationalStatusList[8].winterAll = data.winter?Number(Math.round(data.winter.AVG_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[8].winterSunnyMin = data.winterSunny?Number(Math.round(data.winterSunny.MIN_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[8].winterSunnyAvg = data.winterSunny?Number(Math.round(data.winterSunny.AVG_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[8].winterSunnyMax = data.winterSunny?Number(Math.round(data.winterSunny.MAX_EFFL_WQLT_TN * 1000) / 1000).toFixed(3).toString():''; - } - - // 수질-유입(T-P) - if (operationalStatusList?.[9]) { - // 연간 - operationalStatusList[9].yearAvg = data.yearData?Number(Math.round(data.yearData.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[9].yearMax = data.yearData?Number(Math.round(data.yearData.MAX_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[9].yearMin = data.yearData?Number(Math.round(data.yearData.MIN_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 여름 - operationalStatusList[9].summerAll = data.summer?Number(Math.round(data.summer.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[9].summerThree = data.summerRainy?Number(Math.round(data.summerRainy.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[9].summerRain = data.summerSunny?Number(Math.round(data.summerSunny.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 겨울 - operationalStatusList[9].winterAll = data.winter?Number(Math.round(data.winter.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[9].winterSunnyMin = data.winterSunny?Number(Math.round(data.winterSunny.MIN_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[9].winterSunnyAvg = data.winterSunny?Number(Math.round(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[9].winterSunnyMax = data.winterSunny?Number(Math.round(data.winterSunny.MAX_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - } - - // 수질-방류(T-P) - if (operationalStatusList?.[10]) { - // 연간 - operationalStatusList[10].yearAvg = data.yearData?Number(Math.round(data.yearData.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[10].yearMax = data.yearData?Number(Math.round(data.yearData.MAX_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[10].yearMin = data.yearData?Number(Math.round(data.yearData.MIN_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 여름 - operationalStatusList[10].summerAll = data.summer?Number(Math.round(data.summer.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[10].summerThree = data.summerRainy?Number(Math.round(data.summerRainy.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[10].summerRain = data.summerSunny?Number(Math.round(data.summerSunny.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 겨울 - operationalStatusList[10].winterAll = data.winter?Number(Math.round(data.winter.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[10].winterSunnyMin = data.winterSunny?Number(Math.round(data.winterSunny.MIN_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[10].winterSunnyAvg = data.winterSunny?Number(Math.round(data.winterSunny.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[10].winterSunnyMax = data.winterSunny?Number(Math.round(data.winterSunny.MAX_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - } - - /** - * 총인설비 - */ - // - // 유입 - if (operationalStatusList?.[11]) { - // 연간 - operationalStatusList[11].yearAvg = data.yearData?Number(Math.round(data.yearData.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[11].yearMax = data.yearData?Number(Math.round(data.yearData.MAX_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[11].yearMin = data.yearData?Number(Math.round(data.yearData.MIN_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 여름 - operationalStatusList[11].summerAll = data.summer?Number(Math.round(data.summer.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[11].summerThree = data.summerRainy?Number(Math.round(data.summerRainy.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[11].summerRain = data.summerSunny?Number(Math.round(data.summerSunny.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 겨울 - operationalStatusList[11].winterAll = data.winter?Number(Math.round(data.winter.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[11].winterSunnyMin = data.winterSunny?Number(Math.round(data.winterSunny.MIN_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[11].winterSunnyAvg = data.winterSunny?Number(Math.round(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[11].winterSunnyMax = data.winterSunny?Number(Math.round(data.winterSunny.MAX_INFL_ASSCT_BFR_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - } - - // 방류 - if (operationalStatusList?.[12]) { - // 연간 - operationalStatusList[12].yearAvg = data.yearData?Number(Math.round(data.yearData.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[12].yearMax = data.yearData?Number(Math.round(data.yearData.MAX_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[12].yearMin = data.yearData?Number(Math.round(data.yearData.MIN_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 여름 - operationalStatusList[12].summerAll = data.summer?Number(Math.round(data.summer.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[12].summerThree = data.summerRainy?Number(Math.round(data.summerRainy.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[12].summerRain = data.summerSunny?Number(Math.round(data.summerSunny.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - // 겨울 - operationalStatusList[12].winterAll = data.winter?Number(Math.round(data.winter.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[12].winterSunnyMin = data.winterSunny?Number(Math.round(data.winterSunny.MIN_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[12].winterSunnyAvg = data.winterSunny?Number(Math.round(data.winterSunny.AVG_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; - operationalStatusList[12].winterSunnyMax = data.winterSunny?Number(Math.round(data.winterSunny.MAX_EFFL_WQLT_TP * 1000) / 1000).toFixed(3).toString():''; + for(let i=1; i DashBoardType) const efflWqltTp = [0, 0, 0, 0, 0, 0, 0, 0, 0]; // Process the data and create rain management list res.data.wqltObjs.forEach((item: RainManageListProps) => { + // 강우일 if(Number(item.infoRnDay) < 3){ rainDate[1] = Number(rainDate[1] || 0) + 1; diff --git a/apps/fo/components.json b/apps/fo/components.json index dea737b85..33cf79ee5 100644 --- a/apps/fo/components.json +++ b/apps/fo/components.json @@ -12,6 +12,7 @@ }, "aliases": { "components": "@/components", + "src": "@/src", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", diff --git a/apps/fo/middleware.ts b/apps/fo/middleware.ts index c3e2a5bec..317c6a706 100644 --- a/apps/fo/middleware.ts +++ b/apps/fo/middleware.ts @@ -1,8 +1,8 @@ import { NextRequest, NextResponse } from "next/server"; +import { SERVER_API_CS_URL } from "./src/shared/config/env"; const AUTH_USER_ID = process.env.NEXT_PUBLIC_AUTH_USER_ID || "token-id"; const CLAIM_NAME = process.env.NEXT_PUBLIC_CLAIM_NAME || "Authorization"; -const SERVER_API_URL = process.env.NEXT_PUBLIC_SERVER_API_URL || ""; const GEOSERVER_URL = process.env.NEXT_PUBLIC_GEOSERVER_URL || ""; const LX_GEOSERVER_URL = process.env.NEXT_PUBLIC_LX_GEOSERVER_URL || ""; const SEWERAGE_API_URL = process.env.NEXT_PUBLIC_SEWERAGE_API_URL || ""; @@ -14,7 +14,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/server")) { const queryParams = searchParams.toString(); - const newUrl = `${SERVER_API_URL}${pathname.replace("/server", "")}${ + const newUrl = `${SERVER_API_CS_URL}${pathname.replace("/server", "")}${ queryParams ? `?${queryParams}` : "" }`; console.log(`[Middleware] Rewriting from '/server' path to: ${newUrl}`); @@ -76,7 +76,7 @@ export function middleware(req: NextRequest) { const requestHeaders = new Headers(req.headers); const token = req.cookies.get(CLAIM_NAME)?.value; const userId = req.cookies.get(AUTH_USER_ID)?.value; - const newUrl = `${SERVER_API_URL}${pathname}`; + const newUrl = `${SERVER_API_CS_URL}${pathname}`; if (token) requestHeaders.set(CLAIM_NAME, token); if (userId) requestHeaders.set(AUTH_USER_ID, userId); @@ -91,7 +91,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/user-service")) { const requestHeaders = new Headers(req.headers); - const newUrl = `${SERVER_API_URL}${pathname}`; + const newUrl = `${SERVER_API_CS_URL}${pathname}`; console.log( `[Middleware] Rewriting from '/user-service' path to: ${newUrl}`, @@ -100,7 +100,9 @@ export function middleware(req: NextRequest) { headers: requestHeaders, }); } - + if (pathname === "/") { + return NextResponse.redirect(new URL("/pages/dashboard", req.url)); + } return NextResponse.next(); } @@ -111,5 +113,6 @@ export const config = { "/attach-service/:path*", "/user-service/:path*", "/cms-service/:path*", + "/" ], }; diff --git a/apps/fo/package.json b/apps/fo/package.json index 447e7d7a7..aedf37c33 100644 --- a/apps/fo/package.json +++ b/apps/fo/package.json @@ -13,6 +13,7 @@ "@common/components": "workspace:*", "@tailwindcss/vite": "^4.0.10", "html2canvas": "^1.4.1", + "js-cookie": "^3.0.5", "next": "15.1.7", "select": "^1.1.2", "webpack": "^5.98.0", diff --git a/apps/fo/src/entities/auth/api/login-service.ts b/apps/fo/src/entities/auth/api/login-service.ts new file mode 100644 index 000000000..fafb467e7 --- /dev/null +++ b/apps/fo/src/entities/auth/api/login-service.ts @@ -0,0 +1,81 @@ + +import type { LoginService, ILogin } from "../model/login-interface"; +import { tokenManager } from "../lib/token-manager"; +import {PROXY_HOST, ACCESS_TOKEN, AUTH_USER_ID,SITE_ID, CLAIM_NAME, ENDPOINT, JWT_EXPIRATION_TIME } from "../../../shared/config"; + +export class LoginApiService implements LoginService { + private static instance: LoginApiService; + + private constructor() {} + + public static getInstance(): LoginApiService { + if (!LoginApiService.instance) { + LoginApiService.instance = new LoginApiService(); + } + return LoginApiService.instance; + } + + public async login(payload: ILogin): Promise { + try { + console.log(' ENDPOINT.USER_SERVICE.LOGIN ', ENDPOINT.USER_SERVICE.LOGIN) + console.log(payload.userId+' '+payload.password) + const response = await fetch( PROXY_HOST+ ENDPOINT.USER_SERVICE.LOGIN, { + method: "POST", + body: JSON.stringify({ + userId: payload.userId, + password: payload.password, + }), + }); + // const data = response.headers.get(ACCESS_TOKEN); + const accessToken = response.headers.get(ACCESS_TOKEN); + const tokenId = response.headers.get(AUTH_USER_ID); + + console.log('accessToken ', accessToken) + console.log('tokenId ', tokenId) + + if (!accessToken || !tokenId) { + throw new Error("Missing required authentication tokens"); + } + + tokenManager.setToken(CLAIM_NAME, accessToken); + tokenManager.setToken(AUTH_USER_ID, tokenId); + tokenManager.setToken("site-id-key", SITE_ID); + tokenManager.setupRefreshTimer( + () => this.silentRefresh(), + JWT_EXPIRATION_TIME, + ); + } catch (error) { + + console.log(' login err ' , error) + throw new Error(`Login failed: ${error}`); + } + } + + + public async silentRefresh(): Promise { + console.log(' silentRefresh ') + + try { + const response = await fetch(PROXY_HOST+ + `${ENDPOINT.USER_SERVICE.SILENT_REFRESH}`, + { method: "PUT" }, + ); + + const data = await response.json(); + const accessToken = data[ACCESS_TOKEN]; + const tokenId = data[AUTH_USER_ID]; + + if (!accessToken || !tokenId) { + throw new Error("Missing required authentication tokens"); + } + + tokenManager.setToken(CLAIM_NAME, accessToken); + tokenManager.setToken(AUTH_USER_ID, tokenId); + } catch (error) { + tokenManager.clearAuthToken(); + throw new Error(`Silent refresh failed: ${error}`); + } + } +} + +export const LoginApi = LoginApiService.getInstance(); diff --git a/apps/fo/src/entities/auth/index.ts b/apps/fo/src/entities/auth/index.ts new file mode 100644 index 000000000..9dc9dd368 --- /dev/null +++ b/apps/fo/src/entities/auth/index.ts @@ -0,0 +1,2 @@ +export { LoginApi } from "./api/login-service"; +//export { AuthWrapper } from "./lib/auth-wrapper"; diff --git a/apps/wr/src/entities/auth/lib/auth-wrapper.tsx b/apps/fo/src/entities/auth/lib/auth-wrapper.tsx similarity index 100% rename from apps/wr/src/entities/auth/lib/auth-wrapper.tsx rename to apps/fo/src/entities/auth/lib/auth-wrapper.tsx diff --git a/apps/fo/src/entities/auth/lib/token-manager.ts b/apps/fo/src/entities/auth/lib/token-manager.ts new file mode 100644 index 000000000..40d32f33e --- /dev/null +++ b/apps/fo/src/entities/auth/lib/token-manager.ts @@ -0,0 +1,59 @@ +import { AUTH_USER_ID, CLAIM_NAME } from "@/src/shared/config"; +import { getCookie, removeCookie, setCookie } from "@/src/shared/lib/cookie"; + +export class TokenManager { + private static instance: TokenManager; + private refreshTimer: NodeJS.Timeout | null = null; + + private constructor() {} + + public static getInstance(): TokenManager { + if (!TokenManager.instance) { + TokenManager.instance = new TokenManager(); + } + return TokenManager.instance; + } + + public getToken(key: string): string | undefined { + return getCookie(key); + } + + public setToken(key: string, value: string): void { + setCookie(key, value, { + secure: window.location.protocol === "https:", + sameSite: "lax", + }); + } + + public removeToken(key: string): void { + removeCookie(key); + } + + public setupRefreshTimer( + callback: () => Promise, + expirationTime: number, + ): void { + if (this.refreshTimer) { + clearTimeout(this.refreshTimer); + } + + this.refreshTimer = setTimeout(() => { + callback().catch((error) => { + console.error("Silent refresh failed:", error); + this.clearAuthToken(); + }); + }, expirationTime - 60000); + } + + public clearAuthToken(): void { + if (this.refreshTimer) { + clearTimeout(this.refreshTimer); + this.refreshTimer = null; + } + + this.removeToken(CLAIM_NAME); + this.removeToken(AUTH_USER_ID); + } +} + +export const tokenManager = TokenManager.getInstance(); diff --git a/apps/fo/src/entities/auth/model/login-interface.ts b/apps/fo/src/entities/auth/model/login-interface.ts new file mode 100644 index 000000000..5aaf53044 --- /dev/null +++ b/apps/fo/src/entities/auth/model/login-interface.ts @@ -0,0 +1,9 @@ +export interface ILogin { + userId: string; + password: string; +} + +export interface LoginService { + login(payload: ILogin): Promise; + silentRefresh(): Promise; +} diff --git a/apps/fo/src/shared/config/api.ts b/apps/fo/src/shared/config/api.ts new file mode 100644 index 000000000..3eba9fa91 --- /dev/null +++ b/apps/fo/src/shared/config/api.ts @@ -0,0 +1,56 @@ +import { PROXY_HOST } from "./env"; + +export const BASE_URL = `${PROXY_HOST}/server`; + +export const ENDPOINT = { + ATTACH_SERVICE: { + TUS_UPLOAD: "/attach-service/api/v1/tus/upload", + EDITOR_UPLOAD: "/attach-service/api/v1/upload/editor", + IMAGES: "/attach-service/api/v1/images", + MOVIE_THUMBNAIL: "/attach-service/api/v1/movie/thumbnail", + ATTACHMENTS: "/attach-service/api/v1/atfl/attachments", + DOWNLOAD: "/attach-service/api/v1/atflcd/download", + STREAM_VIDEO: "/attach-service/api/v1/stream/video", + }, + USER_SERVICE: { + LOGIN: "/user-service/login", + USERS: "/user-service/api/v1/users", + SILENT_REFRESH: "/user-service/api/v1/users/token/refresh", + AUTHORIZATIONS: "/user-service/api/v1/authorizations", + ROLE_AUTHORIZATIONS: "/user-service/api/v1/role-authorizations", + ROLES: "/user-service/api/v1/roles", + }, + CMS_SERVICE: { + SITES: "/cms-service/api/v1/sites", + IPS: "/cms-service/api/v1/site-ips", + DOMAINS: "/cms-service/api/v1/site-dmns", + POSTINGS: "/cms-service/api/v1/site-pstgs", + CODE: "/cms-service/api/v1/code/cache", + MENUS: "/cms-service/api/v1/menus", + MENU_ROLES: "/cms-service/api/v1/menu-roles", + MENU_AUTHRTS: "/cms-service/api/v1/menu-authrts", + CONTENTS: "/cms-service/api/v1/contents", + CONTENTS_DETAILS: "/cms-service/api/v1/contents-details", + ORGANIZATIONS: "/cms-service/api/v1/ognzs", + USER_ORGANIZATION: "/cms-service/api/v1/user-ognz", + IMAGES: "/cms-service/api/v1/images", + BANNERS: "/cms-service/api/v1/bnrs", + TEMPLATE: "/cms-service/api/v1/tmplt", + TERMS: "/cms-service/api/v1/trms", + LWPO_CODE: "/cms-service/api/v1/lwpo-cds", + UP_CODE: "/cms-service/api/v1/up-codes", + POPUPS: "/cms-service/api/v1/popups", + SCHEDULES: "/cms-service/api/v1/schdls", + SURVEY: "/cms-service/api/v1/srvy", + SURVEY_QUESTION: "/cms-service/api/v1/srvy-qitem", + SURVEY_ARTICLE: "/cms-service/api/v1/srvy-artcl", + }, + BOARD_SERVICE: { + BBS: "/board-service/api/v1/bbs", + BBS_TEMPLATES: "/board-service/api/v1/bbsTmplt", + POSTS: "/board-service/api/v1/posts", + POSTS_COMMENTS: "/board-service/api/v1/posts-cmnts", + }, +}; + +export const JWT_EXPIRATION_TIME = 1800000; diff --git a/apps/fo/src/shared/config/env.ts b/apps/fo/src/shared/config/env.ts new file mode 100644 index 000000000..8baf1b0f0 --- /dev/null +++ b/apps/fo/src/shared/config/env.ts @@ -0,0 +1,14 @@ +export const SITE_ID = process.env.NEXT_PUBLIC_SITE_ID || "FO"; +export const PORT = process.env.NEXT_PUBLIC_PORT || "3000"; +export const PROXY_HOST = process.env.NEXT_PUBLIC_PROXY_HOST || `http://localhost:${PORT}`; +export const SERVER_API_WR_URL = process.env.NEXT_PUBLIC_WR_SERVER_API_URL ||'http://con.mind-one.co.kr:11080/api/v1'; +export const SERVER_API_URL = process.env.NEXT_PUBLIC_SERVER_API_URL||' http://con.mind-one.co.kr:11082/api/v1'; +export const SERVER_API_CS_URL = process.env.NEXT_PUBLIC_CS_SERVER_API_URL||'http://dev.onasys.co.kr:8000'; +export const CLAIM_NAME = process.env.NEXT_PUBLIC_CLAIM_NAME || "Authorization"; +export const ACCESS_TOKEN = process.env.NEXT_PUBLIC_ACCESS_TOKEN || "access-token"; +export const REFRESH_TOKEN =process.env.NEXT_PUBLIC_REFRESH_TOKEN || "refresh-token"; +export const AUTH_USER_ID = process.env.NEXT_PUBLIC_AUTH_USER_ID || "token-id"; +export const SERVER_SEWERAGE_API_URL = process.env.NEXT_PUBLIC_SEWERAGE_API_URL; + + + diff --git a/apps/fo/src/shared/config/index.ts b/apps/fo/src/shared/config/index.ts new file mode 100644 index 000000000..cd83447d5 --- /dev/null +++ b/apps/fo/src/shared/config/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./env"; diff --git a/apps/fo/src/shared/lib/cookie.ts b/apps/fo/src/shared/lib/cookie.ts new file mode 100644 index 000000000..4bc0fe142 --- /dev/null +++ b/apps/fo/src/shared/lib/cookie.ts @@ -0,0 +1,31 @@ + +import Cookies from "js-cookie"; + + +export function getCookie(name: string): string | undefined { + if (typeof window === "undefined") { + return undefined; + } + return Cookies.get(name); +} + +export function setCookie( + name: string, + value: string, + options?: Cookies.CookieAttributes, +): void { + if (typeof window === "undefined") { + return; + } + Cookies.set(name, value, options); +} + +export function removeCookie( + name: string, + options?: Cookies.CookieAttributes, +): void { + if (typeof window === "undefined") { + return; + } + Cookies.remove(name, options); +} diff --git a/apps/wr/app/base.tsx b/apps/wr/app/base.tsx new file mode 100644 index 000000000..8ffaa42fe --- /dev/null +++ b/apps/wr/app/base.tsx @@ -0,0 +1,24 @@ +"use client" +import { BaseLayout } from "@common/components/ui" +import { useWrStore } from "./store" +import { MainDiv } from "@common/business_components/ui" +import type { MenuItem } from "./store/common/type/menu" +import { useRouter } from "next/navigation" +export default function Base({ + children, +}: Readonly<{ + children: React.ReactNode +}>) { + const { getMenuAuthrts } = useWrStore((state) => state) + const router = useRouter() + + const changeMenu = (path: MenuItem) => { + getMenuAuthrts(path.menuCd) + router.push(path.urlPath) + } + return ( + + {children} + + ) +} diff --git a/apps/wr/app/layout.tsx b/apps/wr/app/layout.tsx index 38ce0ec4b..add988817 100644 --- a/apps/wr/app/layout.tsx +++ b/apps/wr/app/layout.tsx @@ -1,12 +1,10 @@ -'use client' -import { BaseLayout } from "@common/components"; +"use client"; import "./globals.css"; -import { StoreProvider } from "./store"; -import { MainDiv } from "@common/business_components"; -import koBase from '../public/locales/ko/message.json'; +import { StoreProvider} from "./store"; +import koBase from "../public/locales/ko/message.json"; import i18next from "i18next"; import { I18nextProvider } from "react-i18next"; -import { useRouter } from "next/navigation"; +import Base from "./base"; export default function RootLayout({ children, @@ -14,34 +12,26 @@ export default function RootLayout({ children: React.ReactNode; }>) { i18next.init({ - lng: 'ko', - fallbackLng: 'ko', + lng: "ko", + fallbackLng: "ko", resources: { ko: { base: koBase, }, - } + }, }); - const router = useRouter(); - return ( - { - router.push(e.urlPath) - }} - > - - {children} - - + + {children} + - + ); } diff --git a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx index a1f484b83..d33611128 100644 --- a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx +++ b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx @@ -316,7 +316,7 @@ export default function CoMatRvw() { control={form.control} name="dmndQty" render={({ field }) => ( - + ( String(new Date().getFullYear()) @@ -116,53 +113,65 @@ export default function RuseRvwHstry() { } }; - const form = useForm({ - resolver: zodResolver(DmdCoReqSchema), - mode: "onChange", - }); - const TableCellClick = useCallback( - (index: number | undefined) => { - if ( - index !== undefined && - index >= 0 && - rvwHistRes && - rvwHistRes[index] - ) { - form.reset(rvwHistRes[index]); + (index: number | undefined, headId: string) => { + if (index !== undefined && index >= 0) { + const selectedData = rvwHistData; + if (selectedData && selectedData.length > 0) { + if ( + selectedData[index]?.splyFcltFlg === "검토완료" && + headId === "completeYn" + ) { + setRvwHistData([...selectedData]); + } else if ( + selectedData[index]?.splyFcltFlg === "매칭완료" && + headId === "completeYn" + ) { + toast.error(t("canNotChangeMatStateMsg")); + return; + } + } } }, - [rvwHistRes, form] + [rvwHistData] ); const confrirmToast = () => { const completeData = rvwHistData ?.map((item) => { - form.clearErrors(); - if (item?.completeYn) { + if (item?.completeYn.chk && item.splyFcltFlg === "검토완료") { return Number(item.dmdInfoSn); } }) .filter((item) => item !== undefined); - if (form.formState.isDirty) { - toast((t) => ( - - 표준공사비 정보가 변경되었습니다. 검토 완료 진행시 입력한 정보는 - 초기화 됩니다. -
- 진행하시겠습니까? - - -
- )); + + if (completeData && completeData?.length > 0) { + confirmToast(t('isMatchFinishMsg'), () => ruseRvwComplete(completeData as number[])); + + // const handleConfirm = async () => { + // ruseRvwComplete(completeData as number[]); + // }; + // toast((t) => ( + // + // 매칭완료를 진행하시겠습니까? + //
+ //
+ // + // + //
+ //
+ // )); } else { - ruseRvwComplete(completeData as number[]); + toast.error( t('isNotMatchFinishMsg')); } }; useEffect(() => { @@ -203,11 +212,10 @@ export default function RuseRvwHstry() { rvwCmptnYmd: formatDate(item.demandMatching?.rvwCmptnYmd), mtchnCmptnYmd: formatDate(item.demandMatching?.mtchnCmptnYmd), - ruseUtztnFcltNm: item.ruseUtztnFcltNm, dmndQty: item.dmndQty, splyFcltFlg: flag, - completeYn: false, + completeYn: {chk:flag=="매칭완료", readonly:flag=="매칭완료"}, } as unknown as RvwHistTableType; }); @@ -215,9 +223,6 @@ export default function RuseRvwHstry() { } }, [rvwHistRes]); - useEffect(() => { - console.log("변경여부 ", form.formState.isDirty); - }, [form.formState]); return ( @@ -301,7 +306,7 @@ export default function RuseRvwHstry() { 조회
@@ -319,18 +324,14 @@ export default function RuseRvwHstry() { headlist={ruseHistHeadList} pageSize={20} total={rvwHistCount} - cellClick={(index: number | undefined) => { - TableCellClick(index); + cellClick={(index: number | undefined, headId: string) => { + console.log("테이블 클릭", index); + TableCellClick(index, headId); }} onPageChange={(page) => { setPageNatiion(page); }} > - {/*
-

- 수요신청 상세현황 -

- */} diff --git a/apps/wr/app/matMng/coMng/coSttn/page.tsx b/apps/wr/app/matMng/coMng/coSttn/page.tsx index d385493d9..992b1bdd1 100644 --- a/apps/wr/app/matMng/coMng/coSttn/page.tsx +++ b/apps/wr/app/matMng/coMng/coSttn/page.tsx @@ -101,7 +101,9 @@ export default function CoSttn() { ...item, telno: formatPhoneNumber(item.telno || undefined), regDt: moment(item.regDt).format("YYYY-MM-DD"), - })); + dmdInfoId: `${item.dmdInfoId.slice(0, 3)}-${item.dmdInfoId.slice(3, 5)}-${item.dmdInfoId.slice(5,10)}-${item.dmdInfoId.slice(10)}` + })); + console.log("chData:", chData) // .filter((item: any) => item !== undefined); setBdstTable(chData); } else if (coSttnRes?.length == 0) { diff --git a/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx b/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx index 910923499..36a8b7151 100644 --- a/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx +++ b/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx @@ -43,8 +43,9 @@ export default function LdrmntCoSttn() { const [objSearch, setObjSearch] = useState({ sgg: "", city: "" }); const [bdstTable, setBdstTable] = useState(); const [searchTxt, setSearchTxt] = useState(); - const [excelData, setExcelData] = useState(); + const [excelData, setExcelData] = useState() const [resetPage, isResetPage] = useState(false); + const [isDownloadClicked, setIsDownloadClicked] = useState(false); const { t } = useTranslation('base'); const excelClick = useCallback(() => { @@ -79,10 +80,31 @@ export default function LdrmntCoSttn() { const excelDownloadClick = useCallback(() => { const cityNm = computeCityNm(); + setExcelData(undefined); + setIsDownloadClicked(true); ldrmntSearch(true, 1, String(ldrmntResCount), cityNm, searchTxt || ""); }, [objSearch, searchTxt, code, ldrmntSearch, computeCityNm, ldrmntResCount]); useEffect(() => { + const transData = Array.isArray(excelList) ? excelList : [excelList]; + const exData = tableData(transData, { code }); + const data = Array.isArray(exData) + ? exData.map((item: customLdrmnt) => { + return { + "시도": item.fctryAddr?.split(" ")[0] || "", + "시군구": item.fctryAddr?.split(" ")[1] || "", + "회사명": item.dmdCoNm, + "공장주소": item.fctryAddr, + "공장관리번호": item.fctryMngNo, + "전화번호": item.telno + } + }) : []; + setExcelData(data) + }, [excelList]) + + useEffect(() => { + if (!isDownloadClicked) return; + if (excelData === undefined) return; if (excelData && excelData.length > 0) { downloadExcel({ data: excelData, @@ -93,7 +115,8 @@ export default function LdrmntCoSttn() { } else { toast.error(t('excelDownErrMsg')); } - }, [excelData]); + setIsDownloadClicked(false); + }, [excelData, isDownloadClicked]); const [isExcelOpen, setIsExcelOpen] = useState<{ isModal: boolean; @@ -125,7 +148,7 @@ export default function LdrmntCoSttn() { useEffect(() => { if (!ldrmnt.isInit) { - ldrmntInit("0"); + ldrmntInit(false, "0"); } }, [ldrmnt.isInit, ldrmntInit]); @@ -144,23 +167,6 @@ export default function LdrmntCoSttn() { setBdstTable(tbData); }, [ldrmntRes, code]); - useEffect(() => { - const transData = Array.isArray(excelList) ? excelList : [excelList]; - const exData = tableData(transData, { code }); - const data = Array.isArray(exData) - ? exData.map((item: customLdrmnt) => { - return { - "시도": item.fctryAddr?.split(" ")[0] || "", - "시군구": item.fctryAddr?.split(" ")[1] || "", - "회사명": item.dmdCoNm, - "공장주소": item.fctryAddr, - "공장관리번호": item.fctryMngNo, - "전화번호": item.telno - } - }) : []; - setExcelData(data) - }, [excelList]) - useEffect(() => { ldrmntSearch(false, pageNation, '20', computeCityNm(), searchTxt || ""); isResetPage(false) @@ -264,10 +270,6 @@ export default function LdrmntCoSttn() { }} bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"} body={ { - // confirmToast(t('isUpdateMsg'), await ldrmntUpdate(value)) - // // await ldrmntUpdate(value) - // setDetailModal({ ...detailModal, isOpen: false }) - // ldrmntSearch(false, pageNation, '20', computeCityNm(), searchTxt || ""); const handleConfirm = async () => { await ldrmntUpdate(value); setDetailModal({ ...detailModal, isOpen: false }); @@ -286,12 +288,8 @@ export default function LdrmntCoSttn() { body={ setIsExcelOpen({ isModal: isOpen })} />} /> - - - ) - } \ No newline at end of file diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 5a962fc0a..614a8f90e 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -364,6 +364,7 @@ export default function PublicReuseFaciltyInsert() { setIndexMng(index); }} indexMng={indexMng} + readonly={false} /> diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx index 5f81a0ae8..bd0b9bb8e 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx @@ -3,7 +3,7 @@ import { useWrStore } from "@/app/store"; import { type customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { tableData } from "@/components/lib/func/commom"; +import { formatCommaNumber, tableData } from "@/components/lib/func/commom"; import RainRegForm from "@/components/ui/form/fcltReg/rainReg/rainRegForm"; import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; import { @@ -52,7 +52,7 @@ export default function Home() { : "확인불가"; return { ...item, - archArea: archArea, + archArea: formatCommaNumber(archArea), }; } diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx index 147b9a674..46528bcf7 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx @@ -166,8 +166,8 @@ export default function HtdflSttn() { value={objSearch.sgg} // value props 추가 onSelectValue={getSgg} /> -
-