bracket 내용 수정

This commit is contained in:
hyojun.choi 2025-02-10 15:26:30 +09:00
parent 51bbe46eb1
commit 90541851a1
2 changed files with 89 additions and 19 deletions

View File

@ -186,6 +186,7 @@ export const SAVE_KEY = [
'circuitNumber',
'circuit',
'onlyOffset',
'isChidory',
]
export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype]

View File

@ -114,6 +114,8 @@ export const useTrestle = () => {
leftExposedHalfTopModules.length > 0 ||
rightExposedHalfTopPoints.length > 0
surface.isChidory = isChidory
if (plvrYn === 'N' && isChidory) {
alert('치조불가공법입니다.')
clear()
@ -132,7 +134,6 @@ export const useTrestle = () => {
if (isEaveBar) {
// 처마력바설치 true인 경우 설치
exposedBottomModules.forEach((module) => {
//TODO : 방향별로 처마력바 설치해야함
const bottomPoints = findTopTwoPoints([...module.getCurrentPoints()], direction)
if (!bottomPoints) return
const eaveBar = new fabric.Line([bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y], {
@ -419,7 +420,6 @@ export const useTrestle = () => {
const { width, height } = module
let { x: startX, y: startY } = { ...module.getCenterPoint() }
let { x, y } = { ...module.getCenterPoint() }
//TODO : 방향별로 가대 설치해야함
let leftRows = 1
let hasNextModule = true
@ -506,7 +506,6 @@ export const useTrestle = () => {
const { width, height } = module
let { x: startX, y: startY } = { ...module.getCenterPoint() }
let { x, y } = { ...module.getCenterPoint() }
//TODO : 방향별로 가대 설치해야함
let rightRows = 1
let hasNextModule = true
@ -588,7 +587,7 @@ export const useTrestle = () => {
installBracket(surface)
}
const quotationParam = getTrestleParams(surface)
const quotationParam = getTrestleParams(surface, exposedBottomModules)
surface.set({ quotationParam, isComplete: true })
})
@ -597,7 +596,7 @@ export const useTrestle = () => {
} catch (e) {
// 에러 발생시 가대 초기화
console.error(e)
clear()
// clear()
setViewCircuitNumberTexts(true)
return null
}
@ -1353,8 +1352,8 @@ export const useTrestle = () => {
leftExposedHalfBottomModules.forEach((module) => {
drawBracketWithOutRack(module, rackIntvlPct, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer)
if (rackQty === 3 && findSamePointInBottom(exposedBottomModules, module)) {
// 해당 모듈과 같은 위치 맨 아래에 모듈이 는 경우 하나 더 설치 필요
if (rackQty === 3 && !findSamePointInBottom(exposedBottomModules, module)) {
// 해당 모듈과 같은 위치 맨 아래에 모듈이 는 경우 하나 더 설치 필요
drawBracketWithOutRack(module, rackIntvlPct / 3, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer)
}
if (rackQty === 4) {
@ -1364,7 +1363,7 @@ export const useTrestle = () => {
rightExposedHalfBottomPoints.forEach((module) => {
drawBracketWithOutRack(module, rackIntvlPct, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer)
if (rackQty === 3 && !findSamePointInBottom(exposedBottomModules, module)) {
if (rackQty === 3 && !findSamePointInBottom(exposedBottomModules, module, direction)) {
// 해당 모듈과 같은 위치 맨 아래에 모듈이 없는 경우 하나 더 설치 필요
drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer)
}
@ -1375,12 +1374,35 @@ export const useTrestle = () => {
}
// 방향에 따라 가장 아래모듈중 같은 좌표가 있는지 확인
const findSamePointInBottom = (exposedBottomModules, module) => {
const findSamePointInBottom = (exposedBottomModules, module, direction) => {
const { x, y } = module.getCenterPoint()
return exposedBottomModules.find((exposedBottomModule) => {
const { x: exposedX, y: exposedY } = exposedBottomModule.getCenterPoint()
return Math.abs(x - exposedX) < 2 || Math.abs(y - exposedY) < 2
})
switch (direction) {
case 'south': {
return exposedBottomModules.find((exposedBottomModule) => {
const { x: exposedX, y: exposedY } = exposedBottomModule.getCenterPoint()
return Math.abs(x - exposedX) < 2 && Math.abs(y - exposedY) > module.height
})
}
case 'north': {
return exposedBottomModules.find((exposedBottomModule) => {
const { x: exposedX, y: exposedY } = exposedBottomModule.getCenterPoint()
return Math.abs(x - exposedX) < 2 && Math.abs(y - exposedY) > module.height
})
}
case 'east': {
return exposedBottomModules.find((exposedBottomModule) => {
const { x: exposedX, y: exposedY } = exposedBottomModule.getCenterPoint()
return Math.abs(y - exposedY) < 2 && Math.abs(x - exposedX) > module.width
})
}
case 'west': {
return exposedBottomModules.find((exposedBottomModule) => {
const { x: exposedX, y: exposedY } = exposedBottomModule.getCenterPoint()
return Math.abs(y - exposedY) < 2 && Math.abs(x - exposedX) > module.width
})
}
}
}
const drawBracketWithOutRack = (module, rackIntvlPct, count, l, direction, moduleIntvlHor, moduleIntvlVer) => {
@ -1844,7 +1866,7 @@ export const useTrestle = () => {
}
// 견적서 아이템 조회 api parameter 생성
const getTrestleParams = (surface) => {
const getTrestleParams = (surface, exposedBottomModules) => {
const result = calculateForApi(surface)
const eaveBar = canvas.getObjects().filter((obj) => obj.surfaceId === surface.id && obj.name === 'eaveBar')
@ -1904,7 +1926,7 @@ export const useTrestle = () => {
racks: rackParams,
rackTotCnt: rackList.length ?? 0 + smartRackGroup.length ?? 0,
rackFittingTotCnt: bracketList.length,
moduleRows: getMostLeftModules(surface),
moduleRows: getMostLeftModules(surface, exposedBottomModules),
cvrYn: moduleSelection.construction.setupCover ? 'Y' : 'N',
snowGdYn: moduleSelection.construction.setupSnowCover ? 'Y' : 'N',
plvrYn: cvrPlvrYn,
@ -1954,8 +1976,8 @@ export const useTrestle = () => {
}
// 가장 왼쪽에 있는 모듈을 기준으로 같은 단에 있는 모듈들 파라미터 생성
const getMostLeftModules = (surface) => {
const { direction, modules } = surface
const getMostLeftModules = (surface, exposedBottomModules) => {
const { direction, modules, isChidory } = surface
const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId)
const roofMaterialIndex = parent.roofMaterial.index
const construction = moduleSelectionData?.roofConstructions?.find((construction) => construction.roofIndex === roofMaterialIndex).construction
@ -2002,7 +2024,7 @@ export const useTrestle = () => {
acc[key].push(module)
return acc
}, {})
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => a[0].left - b[0].left)
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => b[0].left - a[0].left)
} else if (direction === 'west') {
const groupedByLeft = modules.reduce((acc, module) => {
const key = module.left
@ -2012,8 +2034,9 @@ export const useTrestle = () => {
acc[key].push(module)
return acc
}, {})
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => b[0].left - a[0].left)
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => a[0].left - b[0].left)
}
sameLineModuleList.forEach((modules, index) => {
const moduleRowResultData = {
seq: index,
@ -2063,13 +2086,46 @@ export const useTrestle = () => {
} = findSideModule(module, surface)
if (bottomModule) {
moduleRowResultData.touchedSurfaceCnt++
if (rackYn === 'N') {
moduleRowResultData.touchedSurfaceBracketCnt += rackQty
}
}
if (!bottomModule) {
if (halfBottomLeftModule && halfBottomRightModule) {
moduleRowResultData.touchedSurfaceCnt++
if (rackYn === 'N') {
moduleRowResultData.touchedSurfaceBracketCnt += rackQty
}
} else if ((halfBottomLeftModule && !halfBottomRightModule) || (!halfBottomLeftModule && halfBottomRightModule)) {
moduleRowResultData.touchedHalfSurfaceCnt++
moduleRowResultData.exposedHalfBottomCnt++
if (rackYn === 'N') {
if (rackQty !== 3) {
// 3개가 아닌경우는 반반
moduleRowResultData.exposedHalfBottomBracketCnt += rackQty / 2
moduleRowResultData.touchedHalfSurfaceBracketCnt += rackQty / 2
} else {
// 3개인 경우 왼쪽 아래가 없는 경우 touched는 2개, exposed는 1개
if (!halfBottomLeftModule && findSamePointInBottom(exposedBottomModules, module, direction)) {
moduleRowResultData.exposedHalfBottomBracketCnt += 2
moduleRowResultData.touchedHalfSurfaceBracketCnt += 1
} else if (!halfBottomLeftModule && !findSamePointInBottom(exposedBottomModules, module, direction)) {
// 왼쪽 아래가 없고, 하단에 같은 점이 없는 경우는 touched는 1개, exposed는 2개
moduleRowResultData.exposedHalfBottomBracketCnt += 1
moduleRowResultData.touchedHalfSurfaceBracketCnt += 2
} else if (!halfBottomRightModule && findSamePointInBottom(exposedBottomModules, module, direction)) {
// 오른쪽 아래가 없고, 하단에 같은 점이 있는 경우는 exposed는 2개, touched는 1개
moduleRowResultData.exposedHalfBottomBracketCnt += 1
moduleRowResultData.touchedHalfSurfaceBracketCnt += 2
} else if (!halfBottomRightModule && !findSamePointInBottom(exposedBottomModules, module, direction)) {
// 오른쪽 아래가 없고, 하단에 같은 점이 없는 경우는 exposed는 1개, touched는 2개
moduleRowResultData.exposedHalfBottomBracketCnt += 2
moduleRowResultData.touchedHalfSurfaceBracketCnt += 1
}
}
}
if (cvrPlvrYn === 'Y') {
moduleRowResultData.eavesHalfCnt++
if (bottomLeftModule || bottomRightModule || halfBottomLeftModule || halfBottomRightModule) {
@ -2079,6 +2135,9 @@ export const useTrestle = () => {
}
} else {
moduleRowResultData.exposedBottomCnt++
if (rackYn === 'N') {
moduleRowResultData.exposedBottomBracketCnt += rackQty
}
if (isEaveBar) {
moduleRowResultData.eavesCnt++
if ((rightModule && !leftModule) || (!rightModule && leftModule)) {
@ -2091,8 +2150,16 @@ export const useTrestle = () => {
if (!topModule) {
if ((halfTopLeftModule && !halfTopRightModule) || (!halfTopLeftModule && halfTopRightModule)) {
moduleRowResultData.exposedHalfTopCnt++
if (rackYn === 'N') {
if (rackQty !== 3) {
moduleRowResultData.exposedHalfTopBracketCnt += rackQty / 2
}
}
} else if (!halfTopLeftModule && !halfTopRightModule) {
moduleRowResultData.exposedTopCnt++
if (rackYn === 'N') {
moduleRowResultData.exposedTopBracketCnt += rackQty
}
}
}
})
@ -2100,6 +2167,8 @@ export const useTrestle = () => {
result.push(moduleRowResultData)
})
canvas.renderAll()
return result
}