Compare commits
3 Commits
fd7ab22754
...
1dfc9c0ac2
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dfc9c0ac2 | |||
| 661da5ec8d | |||
| 65c8535825 |
@ -10,6 +10,8 @@ import { useRouter, useSearchParams } from 'next/navigation'
|
|||||||
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
|
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
|
||||||
import { QcastContext } from '@/app/QcastProvider'
|
import { QcastContext } from '@/app/QcastProvider'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
|
import { POLYGON_TYPE } from '@/common/common'
|
||||||
|
import { logger } from '@/util/logger'
|
||||||
// Constants
|
// Constants
|
||||||
const ESTIMATE_API_ENDPOINT = '/api/estimate' // API 엔드포인트 정의
|
const ESTIMATE_API_ENDPOINT = '/api/estimate' // API 엔드포인트 정의
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ export const useEstimateController = (planNo, flag) => {
|
|||||||
|
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
|
|
||||||
const { promiseGet, post, promisePost } = useAxios(globalLocaleState)
|
const { promiseGet, post, promisePost, get } = useAxios(globalLocaleState)
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const { estimateContextState, setEstimateContextState } = useContext(FloorPlanContext)
|
const { estimateContextState, setEstimateContextState } = useContext(FloorPlanContext)
|
||||||
@ -386,6 +388,36 @@ export const useEstimateController = (planNo, flag) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 견적 상세 저장 후 저장된 plan JSON 에서 회로 payload 를 만들어 CONN_VOL_W(접속용량) 백필을 요청한다.
|
||||||
|
const backfillConnVol = async (objectNo, planNo) => {
|
||||||
|
try {
|
||||||
|
const list = await get({ url: `/api/canvas-management/canvas-statuses/by-object/${objectNo}` })
|
||||||
|
const target = (list || []).find((it) => String(it.planNo) === String(planNo)) || (list || [])[0]
|
||||||
|
const raw = target?.canvasStatus?.replace(/##/g, '"').replace(/∠/g, '∠').replace(/°/g, '°')
|
||||||
|
const objects = raw ? JSON.parse(raw).objects || [] : []
|
||||||
|
|
||||||
|
const moduleObjs = objects.filter((o) => o.name === POLYGON_TYPE.MODULE)
|
||||||
|
const moduleList = moduleObjs.map((m) => ({ circuit: m.circuitNumber, specification: m.moduleInfo?.wpOut }))
|
||||||
|
if (moduleList.length === 0) return
|
||||||
|
|
||||||
|
// PCS 유닛 번호 = circuit 첫 숫자. distinct 개수 = 유닛 수, 오름차순 = 유닛 index
|
||||||
|
const unitNumbers = [...new Set(moduleObjs.map((m) => parseInt(String(m.circuitNumber ?? '').match(/\d+/)?.[0], 10)).filter((n) => n > 0))].sort(
|
||||||
|
(a, b) => a - b
|
||||||
|
)
|
||||||
|
// PCS 데이터는 surfaces[0] 에만 실려 있다.
|
||||||
|
const surface0 = objects.find((o) => o.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
|
const pcsList = (surface0?.pcses || []).filter((pcs) => pcs?.pcsItemId)
|
||||||
|
const circuitItemList = unitNumbers.map((unit) => ({ itemId: pcsList[unit - 1]?.pcsItemId }))
|
||||||
|
|
||||||
|
await promisePost({
|
||||||
|
url: `${ESTIMATE_API_ENDPOINT}/update-conn-vol`,
|
||||||
|
data: { objectNo, planNo, circuitItemList, roofSurfaceList: [{ moduleList }] },
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
logger.log('[UPDATE-CONN-VOL] 백필 호출 실패', e?.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const realSave = async (fileList) => {
|
const realSave = async (fileList) => {
|
||||||
|
|
||||||
setEstimateContextState({pricingFlag: false})
|
setEstimateContextState({pricingFlag: false})
|
||||||
@ -451,9 +483,11 @@ export const useEstimateController = (planNo, flag) => {
|
|||||||
//2. 상세데이터 저장
|
//2. 상세데이터 저장
|
||||||
try {
|
try {
|
||||||
setIsGlobalLoading(true)
|
setIsGlobalLoading(true)
|
||||||
await promisePost({ url: `${ESTIMATE_API_ENDPOINT}/save-estimate`, data: estimateData }).then((res) => {
|
await promisePost({ url: `${ESTIMATE_API_ENDPOINT}/save-estimate`, data: estimateData }).then(async (res) => {
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
estimateData.newFileList = []
|
estimateData.newFileList = []
|
||||||
|
// 인증용량이 CONN_VOL_W 로 계산되므로, /detail 재조회(fetchSetting) 전에 백필을 먼저 끝낸다.
|
||||||
|
await backfillConnVol(estimateData.objectNo, estimateData.planNo)
|
||||||
swalFire({ text: getMessage('estimate.detail.save.alertMsg'), type: 'alert' })
|
swalFire({ text: getMessage('estimate.detail.save.alertMsg'), type: 'alert' })
|
||||||
fetchSetting(estimateData.objectNo, estimateData.planNo)
|
fetchSetting(estimateData.objectNo, estimateData.planNo)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -416,6 +416,9 @@ export const usePolygon = () => {
|
|||||||
while (a > 180) a -= 360
|
while (a > 180) a -= 360
|
||||||
while (a < -180) a += 360
|
while (a < -180) a += 360
|
||||||
const i = Math.round(a / 22.5) // -8 ~ 8
|
const i = Math.round(a / 22.5) // -8 ~ 8
|
||||||
|
// [方位 追加要請 2026-07-03] 124~134°는 西北西/東北東 표시(北西/北東 시작을 135°로) — 북면 판정 ±135°와 표시 경계 일치
|
||||||
|
if (i === 6 && a <= 134) return positive[5] // 北西 → 西北西
|
||||||
|
if (i === -6 && a >= -134) return negative[5] // 北東 → 東北東
|
||||||
return i >= 0 ? positive[i] : negative[-i]
|
return i >= 0 ? positive[i] : negative[-i]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user