Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
yoosangwook 2024-11-21 16:41:52 +09:00
commit 3b9af05002
4 changed files with 213 additions and 230 deletions

View File

@ -36,7 +36,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
}, []) }, [])
const placementRef = { const placementRef = {
isChidori: useRef('true'), isChidori: useRef('false'),
setupLocation: useRef(null), setupLocation: useRef(null),
isMaxSetup: useRef('false'), isMaxSetup: useRef('false'),
} }

View File

@ -3,9 +3,7 @@ import { forwardRef, useState } from 'react'
const Placement = forwardRef((props, refs) => { const Placement = forwardRef((props, refs) => {
const { getMessage } = useMessage() const { getMessage } = useMessage()
const [isChidori, setIsChidori] = useState('true') const [isChidori, setIsChidori] = useState('false')
console.log(refs)
const moduleData = { const moduleData = {
header: [ header: [
@ -107,19 +105,19 @@ const Placement = forwardRef((props, refs) => {
<div className="self-item-td"> <div className="self-item-td">
<div className="pop-form-radio"> <div className="pop-form-radio">
<div className="d-check-radio pop"> <div className="d-check-radio pop">
<input <input type="radio" name="radio01" id="ra01" checked={isChidori === 'true'} value={'true'} onChange={handleChangeChidori} />
type="radio"
name="radio01"
id="ra01"
defaultChecked
checked={isChidori === 'true'}
value={'true'}
onChange={handleChangeChidori}
/>
<label htmlFor="ra01">{getMessage('modal.module.basic.setting.module.placement.do')}</label> <label htmlFor="ra01">{getMessage('modal.module.basic.setting.module.placement.do')}</label>
</div> </div>
<div className="d-check-radio pop"> <div className="d-check-radio pop">
<input type="radio" name="radio02" id="ra02" value={'false'} checked={isChidori === 'false'} onChange={handleChangeChidori} /> <input
type="radio"
name="radio02"
id="ra02"
value={'false'}
defaultChecked
checked={isChidori === 'false'}
onChange={handleChangeChidori}
/>
<label htmlFor="ra02">{getMessage('modal.module.basic.setting.module.placement.do.not')}</label> <label htmlFor="ra02">{getMessage('modal.module.basic.setting.module.placement.do.not')}</label>
</div> </div>
</div> </div>

View File

@ -10,7 +10,7 @@ import { globalLocaleStore } from '@/store/localeAtom'
import { isEmptyArray, isNotEmptyArray, isObjectNotEmpty } from '@/util/common-utils' import { isEmptyArray, isNotEmptyArray, isObjectNotEmpty } from '@/util/common-utils'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { useForm } from 'react-hook-form' import { useForm } from 'react-hook-form'
import { useRecoilValue, useSetRecoilState } from 'recoil' import { useRecoilValue, useSetRecoilState, useResetRecoilState, useRecoilState } from 'recoil'
import { SessionContext } from '@/app/SessionProvider' import { SessionContext } from '@/app/SessionProvider'
import FindAddressPop from './popup/FindAddressPop' import FindAddressPop from './popup/FindAddressPop'
import PlanRequestPop from './popup/PlanRequestPop' import PlanRequestPop from './popup/PlanRequestPop'
@ -20,8 +20,12 @@ import StuffPlanQGrid from './StuffPlanQGrid'
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom' import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
import { ManagementContext } from '@/app/management/ManagementProvider' import { ManagementContext } from '@/app/management/ManagementProvider'
import DocDownOptionPop from '../estimate/popup/DocDownOptionPop' import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
import { stuffSearchState } from '@/store/stuffAtom'
export default function StuffDetail() { export default function StuffDetail() {
const resetStuffRecoil = useResetRecoilState(stuffSearchState)
const stuffSearchParams = useRecoilValue(stuffSearchState)
const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) // const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) //
const [estimatePopupOpen, setEstimatePopupOpen] = useState(false) const [estimatePopupOpen, setEstimatePopupOpen] = useState(false)
@ -433,158 +437,160 @@ export default function StuffDetail() {
}, [commonCode]) }, [commonCode])
useEffect(() => { useEffect(() => {
if (isObjectNotEmpty(managementState)) { if (objectNo) {
// API if (isObjectNotEmpty(managementState)) {
get({ url: '/api/object/prefecture/list' }).then((res) => { // API
if (!isEmptyArray(res)) { get({ url: '/api/object/prefecture/list' }).then((res) => {
setPrefCodeList(res) if (!isEmptyArray(res)) {
} setPrefCodeList(res)
}) }
})
//1 : X167 T01 //1 : X167 T01
//2 : 10X22, 201X112 //2 : 10X22, 201X112
let url let url
let firstList let firstList
let otherList let otherList
let favList let favList
if (session?.storeId === 'T01') { if (session?.storeId === 'T01') {
url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}` url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}`
} else {
if (session.storeLvl === '1') {
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
} else { } else {
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}` if (session.storeLvl === '1') {
} url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
}
get({ url: url }).then((res) => {
if (!isEmptyArray(res)) {
if (session?.storeId === 'T01') {
firstList = res.filter((row) => row.saleStoreLevel === '1')
firstList.sort((a, b) => (a.saleStoreId !== 'T01') - (b.saleStoreId !== 'T01') || a.saleStoreId - b.saleStoreId)
favList = firstList.filter((row) => row.saleStoreId === 'T01' || row.priority !== 'B')
setSaleStoreList(firstList)
setFavoriteStoreList(favList)
setShowSaleStoreList(favList)
if (managementState.firstAgentId != null) {
form.setValue('saleStoreId', managementState.firstAgentId)
setSelOptions(managementState.firstAgentId)
} else {
form.setValue('saleStoreId', managementState.saleStoreId)
setSelOptions(managementState.saleStoreId)
}
// 1 2
let data = managementState?.firstAgentId ? managementState.firstAgentId : managementState.saleStoreId
url = `/api/object/saleStore/${data}/list?firstFlg=0&userId=${session?.userId}`
get({ url: url }).then((res) => {
if (!isEmptyArray(res)) {
res.map((row) => {
row.value = row.saleStoreId
row.label = row.saleStoreName
})
otherList = res
setOriginOtherSaleStoreList(otherList)
setOtherSaleStoreList(otherList)
}
})
} else { } else {
//1 url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
if (session?.storeLvl === '1') {
firstList = res
favList = res.filter((row) => row.priority !== 'B')
otherList = res.filter((row) => row.firstAgentYn === 'N')
setSaleStoreList(firstList)
setFavoriteStoreList(firstList)
setShowSaleStoreList(firstList)
setOtherSaleStoreList(otherList)
} else {
setSelOptions(res[0].saleStoreId)
form.setValue('saleStoreId', res[0].saleStoreId)
form.setValue('saleStoreLevel', res[0].storeLvl)
setSaleStoreList(res)
setFavoriteStoreList(res)
setShowSaleStoreList(res)
otherList = res.filter((row) => row.firstAgentYn === 'N')
setOtherSaleStoreList(otherList)
}
} }
} }
get({ url: url }).then((res) => {
if (!isEmptyArray(res)) {
if (session?.storeId === 'T01') {
firstList = res.filter((row) => row.saleStoreLevel === '1')
firstList.sort((a, b) => (a.saleStoreId !== 'T01') - (b.saleStoreId !== 'T01') || a.saleStoreId - b.saleStoreId)
favList = firstList.filter((row) => row.saleStoreId === 'T01' || row.priority !== 'B')
setSaleStoreList(firstList)
setFavoriteStoreList(favList)
setShowSaleStoreList(favList)
// 1 1 if (managementState.firstAgentId != null) {
// 2 2 1 form.setValue('saleStoreId', managementState.firstAgentId)
if (managementState.saleStoreLevel === '1') { setSelOptions(managementState.firstAgentId)
setSelOptions(managementState.saleStoreId) } else {
form.setValue('saleStoreId', managementState.saleStoreId) form.setValue('saleStoreId', managementState.saleStoreId)
form.setValue('saleStoreLevel', managementState.saleStoreLevel) setSelOptions(managementState.saleStoreId)
} else { }
setOtherSelOptions(managementState.saleStoreId)
form.setValue('otherSaleStoreId', managementState.saleStoreId)
form.setValue('otherSaleStoreLevel', managementState.saleStoreLevel)
form.setValue('saleStoreLevel', '1') // 1 2
}
//No. let data = managementState?.firstAgentId ? managementState.firstAgentId : managementState.saleStoreId
form.setValue('planReqNo', managementState.planReqNo) url = `/api/object/saleStore/${data}/list?firstFlg=0&userId=${session?.userId}`
//
form.setValue('receiveUser', managementState.receiveUser)
//objectStatusId get({ url: url }).then((res) => {
setSelectObjectStatusId(managementState.objectStatusId) if (!isEmptyArray(res)) {
form.setValue('objectStatusId', managementState.objectStatusId) res.map((row) => {
row.value = row.saleStoreId
row.label = row.saleStoreName
})
// otherList = res
form.setValue('objectName', managementState.objectName) setOriginOtherSaleStoreList(otherList)
setOtherSaleStoreList(otherList)
}
})
} else {
//1
if (session?.storeLvl === '1') {
firstList = res
favList = res.filter((row) => row.priority !== 'B')
otherList = res.filter((row) => row.firstAgentYn === 'N')
// setSaleStoreList(firstList)
setSelHonorificCode(managementState.objectNameOmit) setFavoriteStoreList(firstList)
form.setValue('objectNameOmit', managementState.objectNameOmit) setShowSaleStoreList(firstList)
// setOtherSaleStoreList(otherList)
form.setValue('objectNameKana', managementState.objectNameKana) } else {
setSelOptions(res[0].saleStoreId)
form.setValue('saleStoreId', res[0].saleStoreId)
form.setValue('saleStoreLevel', res[0].storeLvl)
setSaleStoreList(res)
setFavoriteStoreList(res)
setShowSaleStoreList(res)
otherList = res.filter((row) => row.firstAgentYn === 'N')
setOtherSaleStoreList(otherList)
}
}
}
// // 1 1
form.setValue('zipNo', managementState.zipNo) // 2 2 1
if (managementState.saleStoreLevel === '1') {
setSelOptions(managementState.saleStoreId)
form.setValue('saleStoreId', managementState.saleStoreId)
form.setValue('saleStoreLevel', managementState.saleStoreLevel)
} else {
setOtherSelOptions(managementState.saleStoreId)
form.setValue('otherSaleStoreId', managementState.saleStoreId)
form.setValue('otherSaleStoreLevel', managementState.saleStoreLevel)
// / form.setValue('saleStoreLevel', '1')
setPrefValue(managementState.prefId) }
form.setValue('prefId', managementState.prefId)
form.setValue('prefName', managementState.prefName)
form.setValue('address', managementState.address)
//
form.setValue('areaId', managementState.areaId)
// //No.
form.setValue('standardWindSpeedId', managementState.standardWindSpeedId) form.setValue('planReqNo', managementState.planReqNo)
// //
form.setValue('verticalSnowCover', managementState.verticalSnowCover) form.setValue('receiveUser', managementState.receiveUser)
// coldRegionFlg 1 true
form.setValue('coldRegionFlg', managementState.coldRegionFlg === '1' ? true : false)
// surfaceType null //objectStatusId
// form.setValue('surfaceType', '') setSelectObjectStatusId(managementState.objectStatusId)
// form.setValue('surfaceType', '') form.setValue('objectStatusId', managementState.objectStatusId)
form.setValue('surfaceType', managementState.surfaceType)
// saltAreaFlg 1 true //
form.setValue('saltAreaFlg', managementState.saltAreaFlg === '1' ? true : false) form.setValue('objectName', managementState.objectName)
//
form.setValue('installHeight', managementState.installHeight) //
// null 0 setSelHonorificCode(managementState.objectNameOmit)
if (managementState.conType === null) { form.setValue('objectNameOmit', managementState.objectNameOmit)
form.setValue('conType', '0')
} else { //
form.setValue('conType', managementState.conType) form.setValue('objectNameKana', managementState.objectNameKana)
}
// //
form.setValue('remarks', managementState.remarks) form.setValue('zipNo', managementState.zipNo)
})
// /
setPrefValue(managementState.prefId)
form.setValue('prefId', managementState.prefId)
form.setValue('prefName', managementState.prefName)
form.setValue('address', managementState.address)
//
form.setValue('areaId', managementState.areaId)
//
form.setValue('standardWindSpeedId', managementState.standardWindSpeedId)
//
form.setValue('verticalSnowCover', managementState.verticalSnowCover)
// coldRegionFlg 1 true
form.setValue('coldRegionFlg', managementState.coldRegionFlg === '1' ? true : false)
// surfaceType null
// form.setValue('surfaceType', '')
// form.setValue('surfaceType', '')
form.setValue('surfaceType', managementState.surfaceType)
// saltAreaFlg 1 true
form.setValue('saltAreaFlg', managementState.saltAreaFlg === '1' ? true : false)
//
form.setValue('installHeight', managementState.installHeight)
// null 0
if (managementState.conType === null) {
form.setValue('conType', '0')
} else {
form.setValue('conType', managementState.conType)
}
//
form.setValue('remarks', managementState.remarks)
})
}
} }
}, [managementState]) }, [managementState])
@ -1267,7 +1273,7 @@ export default function StuffDetail() {
if (res.status === 201) { if (res.status === 201) {
alert(getMessage('stuff.detail.save')) alert(getMessage('stuff.detail.save'))
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`) router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
} }
}) })
} else { } else {
@ -1276,8 +1282,7 @@ export default function StuffDetail() {
if (res.status === 201) { if (res.status === 201) {
setFloorPlanObjectNo({ floorPlanObjectNo: res.data.objectNo }) setFloorPlanObjectNo({ floorPlanObjectNo: res.data.objectNo })
alert(getMessage('stuff.detail.save')) alert(getMessage('stuff.detail.save'))
// router.refresh() router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`)
} }
}) })
} }
@ -1312,6 +1317,7 @@ export default function StuffDetail() {
tempFlg: '1', tempFlg: '1',
workNo: null, workNo: null,
workName: null, workName: null,
objectNo: objectNo ? objectNo : '',
} }
//1 or 2 //1 or 2
@ -1320,16 +1326,27 @@ export default function StuffDetail() {
params.saleStoreLevel = session.storeLvl params.saleStoreLevel = session.storeLvl
} }
await promisePost({ url: '/api/object/save-object', data: params }).then((res) => { const apiUrl = '/api/object/save-object'
if (res.status === 201) { if (objectNo) {
alert(getMessage('stuff.detail.tempSave.message1')) await promisePut({ url: apiUrl, data: params }).then((res) => {
router.push(`${pathname}?objectNo=${res.data.objectNo.toString()}`) if (res.status === 201) {
} alert(getMessage('stuff.detail.save'))
}) router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
} else {
await promisePost({ url: apiUrl, data: params }).then((res) => {
if (res.status === 201) {
alert(getMessage('stuff.detail.save'))
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
}
} }
// //
const onDelete = () => { const onDelete = () => {
// console.log(':::::', stuffSearchParams)
const specificationConfirmDate = managementState.specificationConfirmDate const specificationConfirmDate = managementState.specificationConfirmDate
if (specificationConfirmDate != null) { if (specificationConfirmDate != null) {
alert(getMessage('stuff.detail.delete.message1')) alert(getMessage('stuff.detail.delete.message1'))
@ -1337,6 +1354,12 @@ export default function StuffDetail() {
if (confirm(getMessage('common.message.data.delete'))) { if (confirm(getMessage('common.message.data.delete'))) {
del({ url: `/api/object/${objectNo}` }).then(() => { del({ url: `/api/object/${objectNo}` }).then(() => {
setFloorPlanObjectNo({ floorPlanObjectNo: '' }) setFloorPlanObjectNo({ floorPlanObjectNo: '' })
// console.log('::::::::::')
// resetStuffRecoil()
// stuffSearchParams.code = 'DELETE'
// stuffSearchParams.schSelSaleStoreId = ''
// stuffSearchParams.schOtherSelSaleStoreId = ''
// console.log(' ')
router.push('/management/stuff') router.push('/management/stuff')
}) })
} }

View File

@ -10,6 +10,7 @@ import { useEvent } from '@/hooks/useEvent'
import { POLYGON_TYPE, BATCH_TYPE } from '@/common/common' import { POLYGON_TYPE, BATCH_TYPE } from '@/common/common'
import * as turf from '@turf/turf' import * as turf from '@turf/turf'
import next from 'next'
export function useModuleBasicSetting() { export function useModuleBasicSetting() {
const canvas = useRecoilValue(canvasState) const canvas = useRecoilValue(canvasState)
@ -475,13 +476,6 @@ export function useModuleBasicSetting() {
const bbox = turf.bbox(difference) const bbox = turf.bbox(difference)
let surfaceBbox = {
minX: bbox[0],
maxX: bbox[2],
minY: bbox[1],
maxY: bbox[3],
}
let width = maxLengthLine.flowDirection === 'right' || maxLengthLine.flowDirection === 'left' ? 172.2 : 113.4 let width = maxLengthLine.flowDirection === 'right' || maxLengthLine.flowDirection === 'left' ? 172.2 : 113.4
let height = maxLengthLine.flowDirection === 'right' || maxLengthLine.flowDirection === 'left' ? 113.4 : 172.2 let height = maxLengthLine.flowDirection === 'right' || maxLengthLine.flowDirection === 'left' ? 113.4 : 172.2
@ -490,6 +484,7 @@ export function useModuleBasicSetting() {
width = moduleSetupSurface.flowDirection === 'south' || moduleSetupSurface.flowDirection === 'north' ? 172.2 : 113.4 width = moduleSetupSurface.flowDirection === 'south' || moduleSetupSurface.flowDirection === 'north' ? 172.2 : 113.4
height = moduleSetupSurface.flowDirection === 'south' || moduleSetupSurface.flowDirection === 'north' ? 113.4 : 172.2 height = moduleSetupSurface.flowDirection === 'south' || moduleSetupSurface.flowDirection === 'north' ? 113.4 : 172.2
} }
let cols = Math.floor((bbox[2] - bbox[0]) / width) let cols = Math.floor((bbox[2] - bbox[0]) / width)
let rows = Math.floor((bbox[3] - bbox[1]) / height) let rows = Math.floor((bbox[3] - bbox[1]) / height)
@ -599,6 +594,7 @@ export function useModuleBasicSetting() {
parentId: moduleSetupSurface.parentId, parentId: moduleSetupSurface.parentId,
lineCol: col, lineCol: col,
lineRow: row, lineRow: row,
name: 'module',
}) })
tempModule.setViewLengthText(false) tempModule.setViewLengthText(false)
canvas?.add(tempModule) canvas?.add(tempModule)
@ -619,6 +615,7 @@ export function useModuleBasicSetting() {
parentId: moduleSetupSurface.parentId, parentId: moduleSetupSurface.parentId,
lineCol: col, lineCol: col,
lineRow: row, lineRow: row,
name: 'module',
}) })
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
@ -768,76 +765,41 @@ export function useModuleBasicSetting() {
return hull return hull
} }
function calculatePerpendicularLine(hypotenuseStart, hypotenuseEnd, height) { const calcMinXByHeightDistance = (nowSurface, index, reverse) => {
const { x: x1, y: y1 } = hypotenuseStart function calculateSlopeIntercept(x1, y1, x2, y2) {
const { x: x2, y: y2 } = hypotenuseEnd console.log('Intercept', x1, y1, x2, y2)
// 1. 빗변의 기울기 계산 const slope = (y2 - y1) / (x2 - x1)
const slope = (y2 - y1) / (x2 - x1) const intercept = y1 - slope * x1
// 2. 중점 계산 return { slope, intercept }
const xC = (x1 + x2) / 2
const yC = (y1 + y2) / 2
// 3. 수직 기울기의 정규화 인자 계산
const norm = Math.sqrt(1 + Math.pow(slope, 2))
// 4. 수직선의 끝점 계산
const xOffset = -height / norm
const yOffset = (height * slope) / norm
const point1 = { x: xC + xOffset, y: yC + yOffset }
const point2 = { x: xC - xOffset, y: yC - yOffset }
return { point1, point2 }
}
// 예제 사용
const hypotenuseStart = { x: 2, y: 3 }
const hypotenuseEnd = { x: 8, y: 9 }
const height = 4
const result = calculatePerpendicularLine(hypotenuseStart, hypotenuseEnd, height)
console.log(result)
const calcMinXByHeightDistance = (surface) => {
let minXIndex = surface.lines.reduce((minIdx, current, index, arr) => {
console.log('reduce', minIdx, current, index, arr)
return current.x1 < arr[minIdx].x1 ? index : minIdx
}, surface.lines[0].x1)
console.log('minXIndex', minXIndex)
function calculateIntersection(diagonalA, lineB) {
// Diagonal A coordinates
const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = diagonalA
// Line B coordinates
const { x2: bx2, y2: by2 } = lineB
// Calculate slope (m) and intercept (c) for diagonal A
const slopeA = (ay2 - ay1) / (ax2 - ax1)
const interceptA = ay1 - slopeA * ax1
// Use fixed y (from lineB's y2)
const yFixed = by2
// Calculate x on diagonal A where y = yFixed
const xFixed = (yFixed - interceptA) / slopeA
// Return the intersection point
return { x: xFixed, y: yFixed }
} }
console.log('line', line) let prevLines = nowSurface.lines[(index - 1 + nowSurface.lines.length) % nowSurface.lines.length]
let nextLines = nowSurface.lines[index]
// Example usage: // 선분 정보
const diagonalA = { x1: 490.4, y1: 94.7, x2: 303.7, y2: 654.7 } const l1 = prevLines
const lineB = { x1: 303.7, y1: 654.7, x2: 303.7, y2: 541.3 } const l2 = nextLines
const lineLength = 172.2
const intersection = calculateIntersection(diagonalA, lineB) // l1과 l2의 기울기 및 절편
console.log(`Intersection point: x = ${intersection.x}, y = ${intersection.y}`) let { slope: m1, intercept: b1 } = calculateSlopeIntercept(l1.x1, l1.y1, l1.x2, l1.y2)
let { slope: m2, intercept: b2 } = calculateSlopeIntercept(l2.x1, l2.y1, l2.x2, l2.y2)
console.log(m1, b1, m2, b2)
// 가로선 x1 계산
const x1 = (m2 * lineLength + b2 - b1) / (m1 - m2)
const x2 = x1 + lineLength // 끝점 x2
// 가로선 y값 계산
const y0 = m1 * x1 + b1
// 결과 출력
console.log({ x1: x1, y1: y0, x2: x2, y2: y0 })
return { x1: x1, y1: y0, x2: x2, y2: y0 }
} }
return { return {