Merge branch 'dev' into dev-yj
This commit is contained in:
commit
603c83de53
@ -356,7 +356,7 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
}
|
||||
|
||||
// 회로할당(승압설정) 저장 버튼 클릭 시
|
||||
const onApply = () => {
|
||||
const onApply = async () => {
|
||||
canvas
|
||||
.getObjects()
|
||||
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
@ -364,8 +364,7 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
obj.pcses = getStepUpListData()
|
||||
})
|
||||
|
||||
console.log(canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE))
|
||||
apply()
|
||||
const result = await apply()
|
||||
}
|
||||
|
||||
const onClickPrev = () => {
|
||||
|
||||
@ -248,6 +248,7 @@ export default function StepUp(props) {
|
||||
circuitInfo: module.pcsItemId,
|
||||
})
|
||||
targetModule.circuit = moduleCircuitText
|
||||
targetModule.pcsItemId = module.pcsItemId
|
||||
targetModule.circuitNumber = module.circuit
|
||||
canvas.add(moduleCircuitText)
|
||||
})
|
||||
|
||||
@ -249,8 +249,8 @@ export default function PassivityCircuitAllocation(props) {
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
const pcsItemList = selectedModels.map((model) => {
|
||||
console.log('uniqueCircuitNumbers', uniqueCircuitNumbers)
|
||||
const pcsItemList = selectedModels.map((model, index) => {
|
||||
return {
|
||||
pcsMkrCd: model.pcsMkrCd,
|
||||
pcsSerCd: model.pcsSerCd,
|
||||
@ -260,7 +260,7 @@ export default function PassivityCircuitAllocation(props) {
|
||||
serQtyList: [
|
||||
{
|
||||
serQty: targetModules.length,
|
||||
paralQty: 0,
|
||||
paralQty: uniqueCircuitNumbers.length,
|
||||
rmdYn: 'Y',
|
||||
usePossYn: 'Y',
|
||||
roofSurfaceList: roofSurfaceList,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||
import { canvasState } from '@/store/canvasAtom'
|
||||
import { canvasState, currentAngleTypeSelector } from '@/store/canvasAtom'
|
||||
import { POLYGON_TYPE } from '@/common/common'
|
||||
import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
|
||||
import { getDegreeByChon, getTrestleLength } from '@/util/canvas-util'
|
||||
@ -13,220 +13,207 @@ export const useTrestle = () => {
|
||||
const moduleSelectionData = useRecoilValue(moduleSelectionDataState) //다음으로 넘어가는 최종 데이터
|
||||
const { getQuotationItem } = useMasterController()
|
||||
const [estimateParam, setEstimateParam] = useRecoilState(estimateParamAtom)
|
||||
const currentAngleType = useRecoilValue(currentAngleTypeSelector)
|
||||
|
||||
const apply = () => {
|
||||
//처마력바가 체크되어 있는 경우 exposedBottomPoints를 이용해 처마력바 그려줘야함.
|
||||
// exposedBottomPoints는 노출 최하면 들의 centerPoint 배열.
|
||||
try {
|
||||
//처마력바가 체크되어 있는 경우 exposedBottomPoints를 이용해 처마력바 그려줘야함.
|
||||
// exposedBottomPoints는 노출 최하면 들의 centerPoint 배열.
|
||||
|
||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
// 기존 eaveBar를 삭제
|
||||
canvas.getObjects().forEach((obj) => {
|
||||
if (obj.name === 'eaveBar' || obj.name === 'rack' || obj.name === 'halfEaveBar' || obj.name === 'smartRack') {
|
||||
canvas.remove(obj)
|
||||
}
|
||||
})
|
||||
canvas.getObjects().forEach((obj) => {
|
||||
if (obj.name === 'bracket') {
|
||||
canvas.remove(obj)
|
||||
}
|
||||
})
|
||||
surfaces.forEach((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
|
||||
if (!construction) {
|
||||
alert('앞에서 셋팅 안됨')
|
||||
return
|
||||
}
|
||||
|
||||
let moduleRowsTotCnt = 0
|
||||
let isEaveBar = construction.setupCover
|
||||
let isSnowGuard = construction.setupSnowCover
|
||||
const direction = parent.direction
|
||||
const rack = surface.trestleDetail.rack
|
||||
let { rackQty, rackIntvlPct, rackYn, cvrPlvrYn } = surface.trestleDetail
|
||||
|
||||
if (!rack) {
|
||||
//25/01/16 기준 랙이 없는 경우는 그냥 안그려준다.
|
||||
return
|
||||
}
|
||||
|
||||
const rackInfos = Object.keys(rack).map((key) => {
|
||||
return { key, value: rack[key] }
|
||||
})
|
||||
|
||||
const result = calculateForApi(surface)
|
||||
|
||||
if (!result) {
|
||||
return
|
||||
}
|
||||
const centerPoints = result.centerPoints
|
||||
|
||||
const exposedBottomModules = [] // 아래 두면이 모두 노출 되어있는 경우
|
||||
const leftExposedHalfBottomModules = [] // 왼쪽 면만 노출되어있는 경우
|
||||
const rightExposedHalfBottomPoints = [] // 오른쪽 면만 노출되어 있는 경우
|
||||
const leftExposedHalfTopModules = [] // 왼쪽 면만 노출되어 있는 경우
|
||||
const rightExposedHalfTopPoints = [] // 오른쪽 면만 노출되어 있는 경우
|
||||
const modules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE)
|
||||
|
||||
modules.forEach((module) => {
|
||||
const { x, y } = module.getCenterPoint()
|
||||
const isExposedBottom = result.exposedBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isLeftExposedHalfBottom = result.leftExposedHalfBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isRightExposedHalfBottom = result.rightExposedHalfBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isRightExposedHalfTop = result.rightExposedHalfTopPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isLeftExposedHalfTop = result.leftExposedHalfTopPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
if (isExposedBottom) {
|
||||
exposedBottomModules.push(module)
|
||||
}
|
||||
if (isLeftExposedHalfBottom) {
|
||||
leftExposedHalfBottomModules.push(module)
|
||||
}
|
||||
if (isRightExposedHalfBottom) {
|
||||
rightExposedHalfBottomPoints.push(module)
|
||||
}
|
||||
if (isRightExposedHalfTop) {
|
||||
leftExposedHalfTopModules.push(module)
|
||||
}
|
||||
if (isLeftExposedHalfTop) {
|
||||
rightExposedHalfTopPoints.push(module)
|
||||
}
|
||||
})
|
||||
|
||||
// 4개중 한개라도 있는 경우 치조배치로 간주한다.
|
||||
const isChidory =
|
||||
leftExposedHalfBottomModules.length > 0 ||
|
||||
rightExposedHalfBottomPoints.length > 0 ||
|
||||
leftExposedHalfTopModules.length > 0 ||
|
||||
rightExposedHalfTopPoints.length > 0
|
||||
|
||||
surface.set({ isChidory: isChidory })
|
||||
|
||||
canvas
|
||||
.getObjects()
|
||||
.filter((obj) => ['eaveBar', 'halfEaveBar'].includes(obj.name) && obj.parentId === surface.id)
|
||||
.forEach((obj) => {
|
||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
// 기존 eaveBar를 삭제
|
||||
canvas.getObjects().forEach((obj) => {
|
||||
if (obj.name === 'eaveBar' || obj.name === 'rack' || obj.name === 'halfEaveBar' || obj.name === 'smartRack') {
|
||||
canvas.remove(obj)
|
||||
}
|
||||
})
|
||||
canvas.getObjects().forEach((obj) => {
|
||||
if (obj.name === 'bracket') {
|
||||
canvas.remove(obj)
|
||||
}
|
||||
})
|
||||
surfaces.forEach((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
|
||||
if (!construction) {
|
||||
alert('앞에서 셋팅 안됨')
|
||||
return
|
||||
}
|
||||
|
||||
let moduleRowsTotCnt = 0
|
||||
let isEaveBar = construction.setupCover
|
||||
let isSnowGuard = construction.setupSnowCover
|
||||
const direction = parent.direction
|
||||
const rack = surface.trestleDetail.rack
|
||||
let { rackQty, rackIntvlPct, rackYn, cvrPlvrYn } = surface.trestleDetail
|
||||
|
||||
if (!rack) {
|
||||
//25/01/16 기준 랙이 없는 경우는 그냥 안그려준다.
|
||||
return
|
||||
}
|
||||
|
||||
const rackInfos = Object.keys(rack).map((key) => {
|
||||
return { key, value: rack[key] }
|
||||
})
|
||||
|
||||
if (isEaveBar) {
|
||||
// 처마력바설치 true인 경우 설치
|
||||
exposedBottomModules.forEach((module) => {
|
||||
//TODO : 방향별로 처마력바 설치해야함
|
||||
const bottomPoints = findTopTwoPoints([...module.points], direction)
|
||||
if (!bottomPoints) return
|
||||
const eaveBar = new fabric.Line([bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y], {
|
||||
parent: surface,
|
||||
name: 'eaveBar',
|
||||
stroke: 'blue',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
surfaceId: surface.id,
|
||||
parentId: module.id,
|
||||
const result = calculateForApi(surface)
|
||||
|
||||
if (!result) {
|
||||
return
|
||||
}
|
||||
const centerPoints = result.centerPoints
|
||||
|
||||
const exposedBottomModules = [] // 아래 두면이 모두 노출 되어있는 경우
|
||||
const leftExposedHalfBottomModules = [] // 왼쪽 면만 노출되어있는 경우
|
||||
const rightExposedHalfBottomPoints = [] // 오른쪽 면만 노출되어 있는 경우
|
||||
const leftExposedHalfTopModules = [] // 왼쪽 면만 노출되어 있는 경우
|
||||
const rightExposedHalfTopPoints = [] // 오른쪽 면만 노출되어 있는 경우
|
||||
const modules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE)
|
||||
|
||||
modules.forEach((module) => {
|
||||
const { x, y } = module.getCenterPoint()
|
||||
const isExposedBottom = result.exposedBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isLeftExposedHalfBottom = result.leftExposedHalfBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isRightExposedHalfBottom = result.rightExposedHalfBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isRightExposedHalfTop = result.rightExposedHalfTopPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
const isLeftExposedHalfTop = result.leftExposedHalfTopPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2)
|
||||
if (isExposedBottom) {
|
||||
exposedBottomModules.push(module)
|
||||
}
|
||||
if (isLeftExposedHalfBottom) {
|
||||
leftExposedHalfBottomModules.push(module)
|
||||
}
|
||||
if (isRightExposedHalfBottom) {
|
||||
rightExposedHalfBottomPoints.push(module)
|
||||
}
|
||||
if (isRightExposedHalfTop) {
|
||||
leftExposedHalfTopModules.push(module)
|
||||
}
|
||||
if (isLeftExposedHalfTop) {
|
||||
rightExposedHalfTopPoints.push(module)
|
||||
}
|
||||
})
|
||||
|
||||
// 4개중 한개라도 있는 경우 치조배치로 간주한다.
|
||||
const isChidory =
|
||||
leftExposedHalfBottomModules.length > 0 ||
|
||||
rightExposedHalfBottomPoints.length > 0 ||
|
||||
leftExposedHalfTopModules.length > 0 ||
|
||||
rightExposedHalfTopPoints.length > 0
|
||||
|
||||
surface.set({ isChidory: isChidory })
|
||||
|
||||
canvas
|
||||
.getObjects()
|
||||
.filter((obj) => ['eaveBar', 'halfEaveBar'].includes(obj.name) && obj.parentId === surface.id)
|
||||
.forEach((obj) => {
|
||||
canvas.remove(obj)
|
||||
})
|
||||
canvas.add(eaveBar)
|
||||
canvas.renderAll()
|
||||
})
|
||||
|
||||
if (isChidory && cvrPlvrYn === 'Y') {
|
||||
leftExposedHalfBottomModules.forEach((module) => {
|
||||
if (isEaveBar) {
|
||||
// 처마력바설치 true인 경우 설치
|
||||
exposedBottomModules.forEach((module) => {
|
||||
//TODO : 방향별로 처마력바 설치해야함
|
||||
const bottomPoints = findTopTwoPoints([...module.points], direction)
|
||||
let barPoints = []
|
||||
//설치해야할 반처마커버 포인트를 방향에 따라 설정
|
||||
|
||||
if (direction === 'south') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x - module.width / 2, bottomPoints[1].y]
|
||||
} else if (direction === 'north') {
|
||||
barPoints = [bottomPoints[0].x + module.width / 2, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y]
|
||||
} else if (direction === 'east') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[0].y - module.height / 2]
|
||||
} else if (direction === 'west') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y - module.height / 2]
|
||||
}
|
||||
|
||||
if (!bottomPoints) return
|
||||
const halfEaveBar = new fabric.Line(barPoints, {
|
||||
const eaveBar = new fabric.Line([bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y], {
|
||||
parent: surface,
|
||||
name: 'halfEaveBar',
|
||||
name: 'eaveBar',
|
||||
stroke: 'blue',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
surfaceId: surface.id,
|
||||
parentId: module.id,
|
||||
})
|
||||
canvas.add(halfEaveBar)
|
||||
canvas.add(eaveBar)
|
||||
canvas.renderAll()
|
||||
})
|
||||
|
||||
rightExposedHalfBottomPoints.forEach((module) => {
|
||||
const bottomPoints = findTopTwoPoints([...module.points], direction)
|
||||
let barPoints = []
|
||||
//설치해야할 반처마커버 포인트를 방향에 따라 설정
|
||||
if (isChidory && cvrPlvrYn === 'Y') {
|
||||
leftExposedHalfBottomModules.forEach((module) => {
|
||||
const bottomPoints = findTopTwoPoints([...module.points], direction)
|
||||
let barPoints = []
|
||||
//설치해야할 반처마커버 포인트를 방향에 따라 설정
|
||||
|
||||
if (direction === 'south') {
|
||||
barPoints = [bottomPoints[0].x + module.width / 2, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y]
|
||||
} else if (direction === 'north') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[0].x + module.width / 2, bottomPoints[1].y]
|
||||
} else if (direction === 'east') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[1].y + module.height / 2, bottomPoints[1].x, bottomPoints[1].y]
|
||||
} else if (direction === 'west') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[1].y - module.height / 2, bottomPoints[1].x, bottomPoints[1].y]
|
||||
}
|
||||
if (direction === 'south') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x - module.width / 2, bottomPoints[1].y]
|
||||
} else if (direction === 'north') {
|
||||
barPoints = [bottomPoints[0].x + module.width / 2, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y]
|
||||
} else if (direction === 'east') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[0].y - module.height / 2]
|
||||
} else if (direction === 'west') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y - module.height / 2]
|
||||
}
|
||||
|
||||
if (!bottomPoints) return
|
||||
const halfEaveBar = new fabric.Line(barPoints, {
|
||||
parent: surface,
|
||||
name: 'halfEaveBar',
|
||||
stroke: 'blue',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
parentId: module.id,
|
||||
if (!bottomPoints) return
|
||||
const halfEaveBar = new fabric.Line(barPoints, {
|
||||
parent: surface,
|
||||
name: 'halfEaveBar',
|
||||
stroke: 'blue',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
surfaceId: surface.id,
|
||||
parentId: module.id,
|
||||
})
|
||||
canvas.add(halfEaveBar)
|
||||
canvas.renderAll()
|
||||
})
|
||||
canvas.add(halfEaveBar)
|
||||
canvas.renderAll()
|
||||
})
|
||||
|
||||
rightExposedHalfBottomPoints.forEach((module) => {
|
||||
const bottomPoints = findTopTwoPoints([...module.points], direction)
|
||||
let barPoints = []
|
||||
//설치해야할 반처마커버 포인트를 방향에 따라 설정
|
||||
|
||||
if (direction === 'south') {
|
||||
barPoints = [bottomPoints[0].x + module.width / 2, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y]
|
||||
} else if (direction === 'north') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[0].x + module.width / 2, bottomPoints[1].y]
|
||||
} else if (direction === 'east') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[1].y + module.height / 2, bottomPoints[1].x, bottomPoints[1].y]
|
||||
} else if (direction === 'west') {
|
||||
barPoints = [bottomPoints[0].x, bottomPoints[1].y - module.height / 2, bottomPoints[1].x, bottomPoints[1].y]
|
||||
}
|
||||
|
||||
if (!bottomPoints) return
|
||||
const halfEaveBar = new fabric.Line(barPoints, {
|
||||
parent: surface,
|
||||
name: 'halfEaveBar',
|
||||
stroke: 'blue',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
parentId: module.id,
|
||||
})
|
||||
canvas.add(halfEaveBar)
|
||||
canvas.renderAll()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
const horizontal = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlHor : surface.trestleDetail.moduleIntvlVer
|
||||
const horizontal = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlHor : surface.trestleDetail.moduleIntvlVer
|
||||
|
||||
const vertical = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlVer : surface.trestleDetail.moduleIntvlHor
|
||||
const vertical = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlVer : surface.trestleDetail.moduleIntvlHor
|
||||
|
||||
let mostRowsModule = 0 // 모듈 최대 단 수
|
||||
// 가대 설치를 위한 가장 아래 모듈로부터 위로 몇단인지 계산
|
||||
// 오른쪽,왼쪽 둘 다 아래에 아무것도 없는, 처마 커버를 필요로 하는 모듈
|
||||
exposedBottomModules.forEach((module) => {
|
||||
let { width, height } = { ...module }
|
||||
width = Math.floor(width)
|
||||
height = Math.floor(height)
|
||||
let { x: startX, y: startY } = { ...module.getCenterPoint() }
|
||||
let { x, y } = { ...module.getCenterPoint() }
|
||||
let mostRowsModule = 0 // 모듈 최대 단 수
|
||||
// 가대 설치를 위한 가장 아래 모듈로부터 위로 몇단인지 계산
|
||||
// 오른쪽,왼쪽 둘 다 아래에 아무것도 없는, 처마 커버를 필요로 하는 모듈
|
||||
exposedBottomModules.forEach((module) => {
|
||||
let { width, height } = { ...module }
|
||||
width = Math.floor(width)
|
||||
height = Math.floor(height)
|
||||
let { x: startX, y: startY } = { ...module.getCenterPoint() }
|
||||
let { x, y } = { ...module.getCenterPoint() }
|
||||
|
||||
let leftRows = 1
|
||||
let rightRows = 1
|
||||
let centerRows = 1
|
||||
let hasNextModule = true
|
||||
let findLeft = true
|
||||
let findRight = true
|
||||
let leftRows = 1
|
||||
let rightRows = 1
|
||||
let centerRows = 1
|
||||
let hasNextModule = true
|
||||
let findLeft = true
|
||||
let findRight = true
|
||||
|
||||
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
leftRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findLeft) {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findLeft = false
|
||||
} else {
|
||||
nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findLeft = true
|
||||
}
|
||||
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
@ -234,126 +221,126 @@ export const useTrestle = () => {
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findLeft) {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findLeft = false
|
||||
} else {
|
||||
nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findLeft = true
|
||||
}
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
leftRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasNextModule = true
|
||||
x = startX
|
||||
y = startY
|
||||
hasNextModule = true
|
||||
x = startX
|
||||
y = startY
|
||||
|
||||
// 오른쪽 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
rightRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findRight) {
|
||||
nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = false
|
||||
} else {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = true
|
||||
}
|
||||
// 오른쪽 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
rightRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findRight) {
|
||||
nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = false
|
||||
} else {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = true
|
||||
}
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
rightRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasNextModule = true
|
||||
x = startX
|
||||
y = startY
|
||||
|
||||
// 센터 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
centerRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasNextModule = true
|
||||
x = startX
|
||||
y = startY
|
||||
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const leftRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === leftRows
|
||||
})?.value.racks
|
||||
|
||||
// 센터 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const rightRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === rightRows
|
||||
})?.value.racks
|
||||
// 해당 rack으로 그려준다.
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
centerRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
}
|
||||
}
|
||||
const centerRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === centerRows
|
||||
})?.value.racks
|
||||
|
||||
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const leftRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === leftRows
|
||||
})?.value.racks
|
||||
mostRowsModule = Math.max(leftRows, rightRows, centerRows, mostRowsModule)
|
||||
|
||||
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const rightRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === rightRows
|
||||
})?.value.racks
|
||||
// 해당 rack으로 그려준다.
|
||||
if (rackYn === 'Y') {
|
||||
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
|
||||
drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn)
|
||||
|
||||
const centerRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === centerRows
|
||||
})?.value.racks
|
||||
|
||||
mostRowsModule = Math.max(leftRows, rightRows, centerRows, mostRowsModule)
|
||||
|
||||
if (rackYn === 'Y') {
|
||||
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
|
||||
drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn)
|
||||
|
||||
if (rackQty === 3) {
|
||||
//rack 갯수가 3개인 경우는 중간렉도 추가해줘야함
|
||||
drawRacks(centerRacks, rackQty, rackIntvlPct, module, direction, 'C', rackYn)
|
||||
} else if (rackQty === 4) {
|
||||
drawRacks(leftRacks, rackQty, rackIntvlPct / 3, module, direction, 'L', rackYn)
|
||||
drawRacks(rightRacks, rackQty, rackIntvlPct / 3, module, direction, 'R', rackYn)
|
||||
}
|
||||
}
|
||||
module.set({ leftRows, rightRows, centerRows })
|
||||
})
|
||||
// 왼쪽아래에 모듈이 없는 모듈들
|
||||
leftExposedHalfBottomModules.forEach((module) => {
|
||||
const { width, height } = module
|
||||
let { x: startX, y: startY } = { ...module.getCenterPoint() }
|
||||
let { x, y } = { ...module.getCenterPoint() }
|
||||
//TODO : 방향별로 가대 설치해야함
|
||||
|
||||
let leftRows = 1
|
||||
let hasNextModule = true
|
||||
let findLeft = true
|
||||
|
||||
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
leftRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findLeft) {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findLeft = false
|
||||
} else {
|
||||
nextModule = nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findLeft = true
|
||||
if (rackQty === 3) {
|
||||
//rack 갯수가 3개인 경우는 중간렉도 추가해줘야함
|
||||
drawRacks(centerRacks, rackQty, rackIntvlPct, module, direction, 'C', rackYn)
|
||||
} else if (rackQty === 4) {
|
||||
drawRacks(leftRacks, rackQty, rackIntvlPct / 3, module, direction, 'L', rackYn)
|
||||
drawRacks(rightRacks, rackQty, rackIntvlPct / 3, module, direction, 'R', rackYn)
|
||||
}
|
||||
}
|
||||
module.set({ leftRows, rightRows, centerRows })
|
||||
})
|
||||
// 왼쪽아래에 모듈이 없는 모듈들
|
||||
leftExposedHalfBottomModules.forEach((module) => {
|
||||
const { width, height } = module
|
||||
let { x: startX, y: startY } = { ...module.getCenterPoint() }
|
||||
let { x, y } = { ...module.getCenterPoint() }
|
||||
//TODO : 방향별로 가대 설치해야함
|
||||
|
||||
let leftRows = 1
|
||||
let hasNextModule = true
|
||||
let findLeft = true
|
||||
|
||||
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
@ -361,52 +348,63 @@ export const useTrestle = () => {
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findLeft) {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findLeft = false
|
||||
} else {
|
||||
nextModule = nextModule = findNextRightModule(
|
||||
{
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
horizontal,
|
||||
vertical,
|
||||
},
|
||||
centerPoints,
|
||||
direction,
|
||||
)
|
||||
findLeft = true
|
||||
}
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
leftRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const leftRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === leftRows
|
||||
})?.value.racks
|
||||
mostRowsModule = Math.max(leftRows, mostRowsModule)
|
||||
if (rackYn === 'Y') {
|
||||
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
|
||||
}
|
||||
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const leftRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === leftRows
|
||||
})?.value.racks
|
||||
mostRowsModule = Math.max(leftRows, mostRowsModule)
|
||||
if (rackYn === 'Y') {
|
||||
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
|
||||
}
|
||||
|
||||
module.set({ leftRows })
|
||||
})
|
||||
// 오른쪽 아래에 모듈이 없는 모듈들
|
||||
rightExposedHalfBottomPoints.forEach((module) => {
|
||||
const { width, height } = module
|
||||
let { x: startX, y: startY } = { ...module.getCenterPoint() }
|
||||
let { x, y } = { ...module.getCenterPoint() }
|
||||
//TODO : 방향별로 가대 설치해야함
|
||||
module.set({ leftRows })
|
||||
})
|
||||
// 오른쪽 아래에 모듈이 없는 모듈들
|
||||
rightExposedHalfBottomPoints.forEach((module) => {
|
||||
const { width, height } = module
|
||||
let { x: startX, y: startY } = { ...module.getCenterPoint() }
|
||||
let { x, y } = { ...module.getCenterPoint() }
|
||||
//TODO : 방향별로 가대 설치해야함
|
||||
|
||||
let rightRows = 1
|
||||
let hasNextModule = true
|
||||
let findRight = true
|
||||
let rightRows = 1
|
||||
let hasNextModule = true
|
||||
let findRight = true
|
||||
|
||||
// 오른쪽 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
rightRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findRight) {
|
||||
nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = false
|
||||
} else {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = true
|
||||
}
|
||||
// 오른쪽 찾는다.
|
||||
while (hasNextModule) {
|
||||
//바로 위에 있는지 확인한다.
|
||||
let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
@ -414,43 +412,62 @@ export const useTrestle = () => {
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
// 바로 위가 없을 경우 먼저 왼쪽위가 있는지 확인 한다.
|
||||
if (findRight) {
|
||||
nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = false
|
||||
} else {
|
||||
nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction)
|
||||
findRight = true
|
||||
}
|
||||
|
||||
if (nextModule) {
|
||||
// 바로 위 모듈을 찾는다.
|
||||
rightRows++
|
||||
x = nextModule.x
|
||||
y = nextModule.y
|
||||
} else {
|
||||
hasNextModule = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const rightRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === rightRows
|
||||
})?.value.racks
|
||||
|
||||
mostRowsModule = Math.max(rightRows, mostRowsModule)
|
||||
// 해당 rack으로 그려준다.
|
||||
if (rackYn === 'Y') {
|
||||
drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn)
|
||||
}
|
||||
|
||||
module.set({ rightRows })
|
||||
})
|
||||
|
||||
surface.set({ moduleRowsTotCnt: mostRowsModule })
|
||||
|
||||
if (rackYn === 'N') {
|
||||
// rack이 없을경우
|
||||
installBracketWithOutRack(surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory)
|
||||
} else if (rackYn === 'Y') {
|
||||
installBracket(surface)
|
||||
}
|
||||
|
||||
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
||||
const rightRacks = rackInfos.find((rack) => {
|
||||
return rack.value.moduleRows === rightRows
|
||||
})?.value.racks
|
||||
const quotationParam = getTrestleParams(surface)
|
||||
|
||||
mostRowsModule = Math.max(rightRows, mostRowsModule)
|
||||
// 해당 rack으로 그려준다.
|
||||
if (rackYn === 'Y') {
|
||||
drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn)
|
||||
}
|
||||
|
||||
module.set({ rightRows })
|
||||
surface.set({ quotationParam })
|
||||
})
|
||||
|
||||
surface.set({ moduleRowsTotCnt: mostRowsModule })
|
||||
|
||||
if (rackYn === 'N') {
|
||||
// rack이 없을경우
|
||||
installBracketWithOutRack(surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory)
|
||||
} else if (rackYn === 'Y') {
|
||||
installBracket(surface)
|
||||
}
|
||||
|
||||
const quotationParam = getTrestleParams(surface)
|
||||
|
||||
surface.set({ quotationParam })
|
||||
})
|
||||
setQuoationItem()
|
||||
return setEstimateData()
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// itemList 조회 후 estimateParam에 저장
|
||||
const setQuoationItem = () => {
|
||||
const setEstimateData = async () => {
|
||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
//surfaces.pcses들을 배열로 묶는다
|
||||
const pcses = surfaces[0].pcses
|
||||
@ -461,16 +478,67 @@ export const useTrestle = () => {
|
||||
})
|
||||
const params = { trestles: surfaces.map((surface) => surface.quotationParam), pcses }
|
||||
//견적서 itemList 조회
|
||||
getQuotationItem(params).then((res) => {
|
||||
if (!res.data) {
|
||||
return
|
||||
}
|
||||
const itemList = res.data
|
||||
//northArrangement 북면 설치 여부
|
||||
const northArrangement = getNorthArrangement()
|
||||
const res = await getQuotationItem(params)
|
||||
if (!res.data) {
|
||||
return false
|
||||
}
|
||||
const itemList = res.data
|
||||
//northArrangement 북면 설치 여부
|
||||
const northArrangement = getNorthArrangement()
|
||||
// circuitItemList의 경우는 moduleList에서 circuitId만 groupBy한다.
|
||||
let circuitItemList = []
|
||||
|
||||
setEstimateParam({ ...estimateParam, itemList, northArrangement })
|
||||
// roofSurfaceList 생성
|
||||
const roofSurfaceList = surfaces.map((surface) => {
|
||||
const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId)
|
||||
const { directionText, roofMaterial, pitch: slope, moduleCompass, surfaceCompass } = parent
|
||||
const roofMaterialIndex = parent.roofMaterial.index
|
||||
const { nameJp: roofMaterialIdMulti } = roofMaterial
|
||||
const moduleSelection = moduleSelectionData?.roofConstructions?.find((construction) => construction.roofIndex === roofMaterialIndex)
|
||||
const { constTp: constructSpecification, constTpJp: constructSpecificationMulti } = moduleSelection.construction
|
||||
const {
|
||||
trestleMkrCd,
|
||||
constMthdCd: supportMethodId,
|
||||
roofBaseCd,
|
||||
trestleMkrCdJp: supportMeaker,
|
||||
constMthdCdJp: supportMethodIdMulti,
|
||||
} = moduleSelection.trestle
|
||||
|
||||
const modules = surface.modules
|
||||
const moduleList = modules.map((module) => {
|
||||
circuitItemList.push(module.pcsItemId)
|
||||
return {
|
||||
itemId: module.moduleInfo.itemId,
|
||||
circuit: module.circuitNumber,
|
||||
pcItemId: module.pcsItemId,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
roofSurfaceId: surface.id,
|
||||
roofSurface: directionText.replace(/[^0-9]/g, ''),
|
||||
roofMaterialId: roofMaterial.roofMatlCd,
|
||||
supportMethodId,
|
||||
constructSpecification,
|
||||
constructSpecificationMulti,
|
||||
roofMaterialIdMulti,
|
||||
supportMethodIdMulti,
|
||||
supportMeaker,
|
||||
slope,
|
||||
classType: currentAngleType === 'slope' ? '0' : '1',
|
||||
angle: getDegreeByChon(slope),
|
||||
azimuth: surfaceCompass ?? moduleCompass ?? 0,
|
||||
moduleList,
|
||||
}
|
||||
})
|
||||
|
||||
// circuitItemList 중복제거
|
||||
circuitItemList = circuitItemList.filter((item, index) => circuitItemList.indexOf(item) === index)
|
||||
|
||||
setEstimateParam({ ...estimateParam, itemList, northArrangement, roofSurfaceList, circuitItemList })
|
||||
|
||||
// 정상적으로 완료 되면 true 반환
|
||||
return true
|
||||
}
|
||||
|
||||
const getNorthArrangement = () => {
|
||||
|
||||
@ -14,7 +14,7 @@ export const estimateParamAtom = atom({
|
||||
standardWindSpeedId: '',
|
||||
snowfall: '',
|
||||
northArrangement: '',
|
||||
drawingFlg: '',
|
||||
drawingFlg: '1',
|
||||
userId: '',
|
||||
roofSurfaceList: [],
|
||||
circuitItemList: [],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user