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 = {
isChidori: useRef('true'),
isChidori: useRef('false'),
setupLocation: useRef(null),
isMaxSetup: useRef('false'),
}

View File

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

View File

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

View File

@ -10,6 +10,7 @@ import { useEvent } from '@/hooks/useEvent'
import { POLYGON_TYPE, BATCH_TYPE } from '@/common/common'
import * as turf from '@turf/turf'
import next from 'next'
export function useModuleBasicSetting() {
const canvas = useRecoilValue(canvasState)
@ -475,13 +476,6 @@ export function useModuleBasicSetting() {
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 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
height = moduleSetupSurface.flowDirection === 'south' || moduleSetupSurface.flowDirection === 'north' ? 113.4 : 172.2
}
let cols = Math.floor((bbox[2] - bbox[0]) / width)
let rows = Math.floor((bbox[3] - bbox[1]) / height)
@ -599,6 +594,7 @@ export function useModuleBasicSetting() {
parentId: moduleSetupSurface.parentId,
lineCol: col,
lineRow: row,
name: 'module',
})
tempModule.setViewLengthText(false)
canvas?.add(tempModule)
@ -619,6 +615,7 @@ export function useModuleBasicSetting() {
parentId: moduleSetupSurface.parentId,
lineCol: col,
lineRow: row,
name: 'module',
})
canvas?.add(tempModule)
moduleSetupArray.push(tempModule)
@ -768,76 +765,41 @@ export function useModuleBasicSetting() {
return hull
}
function calculatePerpendicularLine(hypotenuseStart, hypotenuseEnd, height) {
const { x: x1, y: y1 } = hypotenuseStart
const { x: x2, y: y2 } = hypotenuseEnd
const calcMinXByHeightDistance = (nowSurface, index, reverse) => {
function calculateSlopeIntercept(x1, y1, x2, y2) {
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. 중점 계산
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 }
return { slope, intercept }
}
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 lineB = { x1: 303.7, y1: 654.7, x2: 303.7, y2: 541.3 }
// 선분 정보
const l1 = prevLines
const l2 = nextLines
const lineLength = 172.2
const intersection = calculateIntersection(diagonalA, lineB)
console.log(`Intersection point: x = ${intersection.x}, y = ${intersection.y}`)
// l1과 l2의 기울기 및 절편
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 {