혼합모듈 대응작업중
This commit is contained in:
parent
ae34bb741e
commit
ffbce942d6
@ -337,7 +337,6 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
|
|
||||||
const result = await apply()
|
const result = await apply()
|
||||||
removeNotAllocationModules()
|
removeNotAllocationModules()
|
||||||
apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeNotAllocationModules = () => {
|
const removeNotAllocationModules = () => {
|
||||||
|
|||||||
@ -41,6 +41,7 @@ export const useTrestle = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const plvrYn = construction.plvrYn
|
||||||
let moduleRowsTotCnt = 0
|
let moduleRowsTotCnt = 0
|
||||||
let isEaveBar = construction.setupCover
|
let isEaveBar = construction.setupCover
|
||||||
let isSnowGuard = construction.setupSnowCover
|
let isSnowGuard = construction.setupSnowCover
|
||||||
@ -102,6 +103,14 @@ export const useTrestle = () => {
|
|||||||
leftExposedHalfTopModules.length > 0 ||
|
leftExposedHalfTopModules.length > 0 ||
|
||||||
rightExposedHalfTopPoints.length > 0
|
rightExposedHalfTopPoints.length > 0
|
||||||
|
|
||||||
|
console.log('isChidory', isChidory)
|
||||||
|
|
||||||
|
if (plvrYn === 'N' && isChidory) {
|
||||||
|
alert('치조불가공법입니다.')
|
||||||
|
clear()
|
||||||
|
throw new Error('치조불가공법입니다.')
|
||||||
|
}
|
||||||
|
|
||||||
surface.set({ isChidory: isChidory })
|
surface.set({ isChidory: isChidory })
|
||||||
|
|
||||||
canvas
|
canvas
|
||||||
@ -210,6 +219,10 @@ export const useTrestle = () => {
|
|||||||
let findLeft = true
|
let findLeft = true
|
||||||
let findRight = true
|
let findRight = true
|
||||||
|
|
||||||
|
let leftFindModuleList = [module]
|
||||||
|
let rightFindModuleList = [module]
|
||||||
|
let centerFindModuleList = [module]
|
||||||
|
|
||||||
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
||||||
while (hasNextModule) {
|
while (hasNextModule) {
|
||||||
//바로 위에 있는지 확인한다.
|
//바로 위에 있는지 확인한다.
|
||||||
@ -218,6 +231,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
leftRows++
|
leftRows++
|
||||||
|
leftFindModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -233,6 +247,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
leftRows++
|
leftRows++
|
||||||
|
leftFindModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -253,6 +268,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
rightRows++
|
rightRows++
|
||||||
|
rightFindModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -268,6 +284,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
rightRows++
|
rightRows++
|
||||||
|
rightFindModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -287,6 +304,7 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
|
centerFindModuleList.push(nextModule)
|
||||||
centerRows++
|
centerRows++
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
@ -295,19 +313,77 @@ export const useTrestle = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const leftModuleInfos = leftFindModuleList.map((module) => {
|
||||||
|
return {
|
||||||
|
moduleTpCd: module.moduleInfo.moduleTpCd,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const rightModuleInfos = rightFindModuleList.map((module) => {
|
||||||
|
return {
|
||||||
|
moduleTpCd: module.moduleInfo.moduleTpCd,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const centerModuleInfos = centerFindModuleList.map((module) => {
|
||||||
|
return {
|
||||||
|
moduleTpCd: module.moduleInfo.moduleTpCd,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const leftRowsInfo = moduleTransformData(leftModuleInfos)
|
||||||
|
const rightRowsInfo = moduleTransformData(rightModuleInfos)
|
||||||
|
const centerRowsInfo = moduleTransformData(centerModuleInfos)
|
||||||
|
|
||||||
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
||||||
const leftRacks = rackInfos.find((rack) => {
|
const leftRacks = rackInfos.find((rack) => {
|
||||||
return rack.value.moduleRows === leftRows
|
if (leftRowsInfo.rowsInfo.length === 1) {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
|
rack.value.moduleTpRows1 === leftRowsInfo.rowsInfo[0].count &&
|
||||||
|
rack.value.moduleTpRows2 === leftRowsInfo.rowsInfo[1].count
|
||||||
|
)
|
||||||
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
|
|
||||||
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
||||||
const rightRacks = rackInfos.find((rack) => {
|
const rightRacks = rackInfos.find((rack) => {
|
||||||
return rack.value.moduleRows === rightRows
|
if (rightRowsInfo.rowsInfo.length === 1) {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
|
rack.value.moduleTpRows1 === rightRowsInfo.rowsInfo[0].count &&
|
||||||
|
rack.value.moduleTpRows2 === rightRowsInfo.rowsInfo[1].count
|
||||||
|
)
|
||||||
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
// 해당 rack으로 그려준다.
|
// 해당 rack으로 그려준다.
|
||||||
|
|
||||||
const centerRacks = rackInfos.find((rack) => {
|
const centerRacks = rackInfos.find((rack) => {
|
||||||
return rack.value.moduleRows === centerRows
|
if (centerRowsInfo.rowsInfo.length === 1) {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === centerRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === centerRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === centerRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === centerRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
|
rack.value.moduleTpRows1 === centerRowsInfo.rowsInfo[0].count &&
|
||||||
|
rack.value.moduleTpRows2 === centerRowsInfo.rowsInfo[1].count
|
||||||
|
)
|
||||||
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
|
|
||||||
mostRowsModule = Math.max(leftRows, rightRows, centerRows, mostRowsModule)
|
mostRowsModule = Math.max(leftRows, rightRows, centerRows, mostRowsModule)
|
||||||
@ -336,6 +412,7 @@ export const useTrestle = () => {
|
|||||||
let leftRows = 1
|
let leftRows = 1
|
||||||
let hasNextModule = true
|
let hasNextModule = true
|
||||||
let findLeft = true
|
let findLeft = true
|
||||||
|
let findModuleList = [module]
|
||||||
|
|
||||||
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
//우선 절반을 나눈 뒤 왼쪽부터 찾는다.
|
||||||
while (hasNextModule) {
|
while (hasNextModule) {
|
||||||
@ -345,6 +422,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
leftRows++
|
leftRows++
|
||||||
|
findModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -371,6 +449,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
leftRows++
|
leftRows++
|
||||||
|
findModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -379,10 +458,30 @@ export const useTrestle = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const leftModuleInfos = findModuleList.map((module) => {
|
||||||
|
return {
|
||||||
|
moduleTpCd: module.moduleInfo.moduleTpCd,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const leftRowsInfo = moduleTransformData(leftModuleInfos)
|
||||||
|
|
||||||
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
// 모듈의 왼쪽 부터 그릴 랙 정보를 가져온다.
|
||||||
const leftRacks = rackInfos.find((rack) => {
|
const leftRacks = rackInfos.find((rack) => {
|
||||||
return rack.value.moduleRows === leftRows
|
if (leftRowsInfo.rowsInfo.length === 1) {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
|
rack.value.moduleTpRows1 === leftRowsInfo.rowsInfo[0].count &&
|
||||||
|
rack.value.moduleTpRows2 === leftRowsInfo.rowsInfo[1].count
|
||||||
|
)
|
||||||
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
|
|
||||||
mostRowsModule = Math.max(leftRows, mostRowsModule)
|
mostRowsModule = Math.max(leftRows, mostRowsModule)
|
||||||
if (rackYn === 'Y') {
|
if (rackYn === 'Y') {
|
||||||
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
|
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
|
||||||
@ -400,6 +499,7 @@ export const useTrestle = () => {
|
|||||||
let rightRows = 1
|
let rightRows = 1
|
||||||
let hasNextModule = true
|
let hasNextModule = true
|
||||||
let findRight = true
|
let findRight = true
|
||||||
|
let findModuleList = [module]
|
||||||
|
|
||||||
// 오른쪽 찾는다.
|
// 오른쪽 찾는다.
|
||||||
while (hasNextModule) {
|
while (hasNextModule) {
|
||||||
@ -409,6 +509,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
rightRows++
|
rightRows++
|
||||||
|
findModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -424,6 +525,7 @@ export const useTrestle = () => {
|
|||||||
if (nextModule) {
|
if (nextModule) {
|
||||||
// 바로 위 모듈을 찾는다.
|
// 바로 위 모듈을 찾는다.
|
||||||
rightRows++
|
rightRows++
|
||||||
|
findModuleList.push(nextModule)
|
||||||
x = nextModule.x
|
x = nextModule.x
|
||||||
y = nextModule.y
|
y = nextModule.y
|
||||||
} else {
|
} else {
|
||||||
@ -432,11 +534,30 @@ export const useTrestle = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rightRowsInfos = findModuleList.map((module) => {
|
||||||
|
return {
|
||||||
|
moduleTpCd: module.moduleInfo.moduleTpCd,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const rightRowsInfo = moduleTransformData(rightRowsInfos)
|
||||||
|
|
||||||
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
// 모듈의 오른쪽 부터 그릴 랙 정보를 가져온다.
|
||||||
const rightRacks = rackInfos.find((rack) => {
|
const rightRacks = rackInfos.find((rack) => {
|
||||||
return rack.value.moduleRows === rightRows
|
if (rightRowsInfo.rowsInfo.length === 1) {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
||||||
|
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
|
rack.value.moduleTpRows1 === rightRowsInfo.rowsInfo[0].count &&
|
||||||
|
rack.value.moduleTpRows2 === rightRowsInfo.rowsInfo[1].count
|
||||||
|
)
|
||||||
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
|
|
||||||
mostRowsModule = Math.max(rightRows, mostRowsModule)
|
mostRowsModule = Math.max(rightRows, mostRowsModule)
|
||||||
// 해당 rack으로 그려준다.
|
// 해당 rack으로 그려준다.
|
||||||
if (rackYn === 'Y') {
|
if (rackYn === 'Y') {
|
||||||
@ -462,10 +583,25 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
return setEstimateData()
|
return setEstimateData()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//module Rack 정보를 얻기위한 데이터 가공
|
||||||
|
function moduleTransformData(arr) {
|
||||||
|
let counts = {}
|
||||||
|
|
||||||
|
arr.forEach((item) => {
|
||||||
|
counts[item.moduleTpCd] = (counts[item.moduleTpCd] || 0) + 1
|
||||||
|
})
|
||||||
|
|
||||||
|
let moduleTotalTp = Object.keys(counts).join('')
|
||||||
|
let rowsInfo = Object.entries(counts).map(([moduleTpCd, count]) => ({ moduleTpCd, count }))
|
||||||
|
|
||||||
|
return { moduleTotalTp, rowsInfo }
|
||||||
|
}
|
||||||
|
|
||||||
// itemList 조회 후 estimateParam에 저장
|
// itemList 조회 후 estimateParam에 저장
|
||||||
const setEstimateData = async () => {
|
const setEstimateData = async () => {
|
||||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
@ -565,9 +701,11 @@ export const useTrestle = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const findNextModule = (currentPoint, centerPoints, direction) => {
|
const findNextModule = (currentPoint, centerPoints, direction) => {
|
||||||
let { x, y, width, height, horizontal, vertical } = { ...currentPoint }
|
let { x, y, horizontal, vertical } = { ...currentPoint }
|
||||||
width = width + horizontal
|
let { widthArr, heightArr } = centerPoints[0]
|
||||||
height = height + vertical
|
|
||||||
|
let width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
|
let height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
||||||
|
|
||||||
let maxX = 2 + horizontal * 3
|
let maxX = 2 + horizontal * 3
|
||||||
let maxY = 2 + vertical * 3
|
let maxY = 2 + vertical * 3
|
||||||
@ -596,7 +734,11 @@ export const useTrestle = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const findNextLeftModule = (currentPoint, centerPoints, direction) => {
|
const findNextLeftModule = (currentPoint, centerPoints, direction) => {
|
||||||
let { x, y, width, height, horizontal, vertical } = { ...currentPoint }
|
let { x, y, horizontal, vertical } = { ...currentPoint }
|
||||||
|
let { widthArr, heightArr } = centerPoints[0]
|
||||||
|
|
||||||
|
let width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
|
let height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
||||||
|
|
||||||
let result
|
let result
|
||||||
let topLeftPoint
|
let topLeftPoint
|
||||||
@ -631,9 +773,11 @@ export const useTrestle = () => {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
const findNextRightModule = (currentPoint, centerPoints, direction) => {
|
const findNextRightModule = (currentPoint, centerPoints, direction) => {
|
||||||
let { x, y, width, height, horizontal, vertical } = { ...currentPoint }
|
let { x, y, horizontal, vertical } = { ...currentPoint }
|
||||||
width = width + horizontal
|
let { widthArr, heightArr } = centerPoints[0]
|
||||||
height = height + vertical
|
|
||||||
|
let width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
|
let height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
||||||
let result
|
let result
|
||||||
let topRightPoint
|
let topRightPoint
|
||||||
|
|
||||||
@ -665,6 +809,9 @@ export const useTrestle = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const drawRacks = (rackInfos, rackQty, rackIntvlPct, module, direction, l, rackYn) => {
|
const drawRacks = (rackInfos, rackQty, rackIntvlPct, module, direction, l, rackYn) => {
|
||||||
|
if (!rackInfos) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const { width, height, left, top, lastX, lastY, surfaceId } = module
|
const { width, height, left, top, lastX, lastY, surfaceId } = module
|
||||||
const surface = canvas.getObjects().find((obj) => obj.id === surfaceId)
|
const surface = canvas.getObjects().find((obj) => obj.id === surfaceId)
|
||||||
const roof = canvas.getObjects().find((obj) => obj.id === surface.parentId)
|
const roof = canvas.getObjects().find((obj) => obj.id === surface.parentId)
|
||||||
@ -762,7 +909,7 @@ export const useTrestle = () => {
|
|||||||
name: 'smartRack',
|
name: 'smartRack',
|
||||||
stroke: 'red',
|
stroke: 'red',
|
||||||
strokeWidth: 4,
|
strokeWidth: 4,
|
||||||
selectable: false,
|
selectable: true,
|
||||||
shadow: {
|
shadow: {
|
||||||
color: 'black', // Outline color
|
color: 'black', // Outline color
|
||||||
blur: 10,
|
blur: 10,
|
||||||
@ -774,17 +921,18 @@ export const useTrestle = () => {
|
|||||||
surfaceId: surface.id,
|
surfaceId: surface.id,
|
||||||
supFitQty,
|
supFitQty,
|
||||||
supFitIntvlPct,
|
supFitIntvlPct,
|
||||||
rackLen,
|
rackLen: rackLength,
|
||||||
rackRowsCd,
|
rackRowsCd,
|
||||||
seq,
|
seq,
|
||||||
smartRackId,
|
smartRackId,
|
||||||
rackId: itemId,
|
rackId: itemId,
|
||||||
direction: 'top',
|
direction: 'top',
|
||||||
})
|
})
|
||||||
|
startPointY -= rackLength + 8
|
||||||
canvas.add(rack)
|
canvas.add(rack)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
} else if (setRackTpCd === 'INTVL') {
|
} else if (setRackTpCd === 'INTVL') {
|
||||||
startPointY -= rackLength + 8
|
startPointY -= rackLength
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -844,13 +992,14 @@ export const useTrestle = () => {
|
|||||||
surfaceId: surface.id,
|
surfaceId: surface.id,
|
||||||
supFitQty,
|
supFitQty,
|
||||||
supFitIntvlPct,
|
supFitIntvlPct,
|
||||||
rackLen,
|
rackLen: rackLength,
|
||||||
rackRowsCd,
|
rackRowsCd,
|
||||||
seq,
|
seq,
|
||||||
smartRackId,
|
smartRackId,
|
||||||
rackId: itemId,
|
rackId: itemId,
|
||||||
direction: 'left',
|
direction: 'left',
|
||||||
})
|
})
|
||||||
|
startPointX -= rackLength + 8
|
||||||
canvas.add(rack)
|
canvas.add(rack)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
} else if (setRackTpCd === 'INTVL') {
|
} else if (setRackTpCd === 'INTVL') {
|
||||||
@ -873,7 +1022,7 @@ export const useTrestle = () => {
|
|||||||
selectable: false,
|
selectable: false,
|
||||||
supFitQty,
|
supFitQty,
|
||||||
supFitIntvlPct,
|
supFitIntvlPct,
|
||||||
rackLen,
|
rackLen: rackLength,
|
||||||
rackYn,
|
rackYn,
|
||||||
rackRowsCd,
|
rackRowsCd,
|
||||||
rackId: itemId,
|
rackId: itemId,
|
||||||
@ -913,17 +1062,18 @@ export const useTrestle = () => {
|
|||||||
surfaceId: surface.id,
|
surfaceId: surface.id,
|
||||||
supFitQty,
|
supFitQty,
|
||||||
supFitIntvlPct,
|
supFitIntvlPct,
|
||||||
rackLen,
|
rackLen: rackLength,
|
||||||
rackRowsCd,
|
rackRowsCd,
|
||||||
seq,
|
seq,
|
||||||
smartRackId,
|
smartRackId,
|
||||||
rackId: itemId,
|
rackId: itemId,
|
||||||
direction: 'right',
|
direction: 'right',
|
||||||
})
|
})
|
||||||
|
startPointX += rackLength + 8
|
||||||
canvas.add(rack)
|
canvas.add(rack)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
} else if (setRackTpCd === 'INTVL') {
|
} else if (setRackTpCd === 'INTVL') {
|
||||||
startPointX += rackLength + 8
|
startPointX += rackLength
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -989,8 +1139,9 @@ export const useTrestle = () => {
|
|||||||
})
|
})
|
||||||
canvas.add(rack)
|
canvas.add(rack)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
} else if (setRackTpCd === 'INTVL') {
|
|
||||||
startPointY += rackLength + 8
|
startPointY += rackLength + 8
|
||||||
|
} else if (setRackTpCd === 'INTVL') {
|
||||||
|
startPointY += rackLength
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -1043,17 +1194,16 @@ export const useTrestle = () => {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
|
|
||||||
racks.forEach((rack) => {
|
racks.forEach((rack) => {
|
||||||
const { x1, y1, x2, y2, direction, supFitQty, supFitIntvlPct, rackLen } = rack
|
const { x1, y1, x2, y2, direction, supFitQty, supFitIntvlPct, rackLen, name } = rack
|
||||||
|
|
||||||
const bracketLength = 10
|
const bracketLength = 10
|
||||||
|
|
||||||
if (direction === 'top') {
|
if (direction === 'top') {
|
||||||
const result = getBracketPoints(supFitQty, supFitIntvlPct)
|
const result = getBracketPoints(supFitQty, supFitIntvlPct)
|
||||||
|
|
||||||
result.forEach((percent) => {
|
result.forEach((percent) => {
|
||||||
const bracket = new fabric.Rect({
|
const bracket = new fabric.Rect({
|
||||||
left: x2 - bracketLength / 3,
|
left: x2 - bracketLength / 3,
|
||||||
top: y2 + (rackLen / 10) * percent,
|
top: name === 'smartRack' ? y2 + rackLen * percent : y2 + (rackLen / 10) * percent,
|
||||||
fill: 'green',
|
fill: 'green',
|
||||||
name: 'bracket',
|
name: 'bracket',
|
||||||
parentId: rack.parentId,
|
parentId: rack.parentId,
|
||||||
@ -1071,7 +1221,7 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
result.forEach((percent) => {
|
result.forEach((percent) => {
|
||||||
const bracket = new fabric.Rect({
|
const bracket = new fabric.Rect({
|
||||||
left: x2 + (rackLen / 10) * percent,
|
left: name === 'smartRack' ? x2 + rackLen * percent : x2 + (rackLen / 10) * percent,
|
||||||
top: y2 - bracketLength / 3,
|
top: y2 - bracketLength / 3,
|
||||||
fill: 'green',
|
fill: 'green',
|
||||||
name: 'bracket',
|
name: 'bracket',
|
||||||
@ -1090,7 +1240,7 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
result.forEach((percent) => {
|
result.forEach((percent) => {
|
||||||
const bracket = new fabric.Rect({
|
const bracket = new fabric.Rect({
|
||||||
left: x2 - (rackLen / 10) * percent,
|
left: name === 'smartRack' ? x2 - rackLen * percent : x2 - (rackLen / 10) * percent,
|
||||||
top: y2 - bracketLength / 3,
|
top: y2 - bracketLength / 3,
|
||||||
fill: 'green',
|
fill: 'green',
|
||||||
parentId: rack.parentId,
|
parentId: rack.parentId,
|
||||||
@ -1110,7 +1260,7 @@ export const useTrestle = () => {
|
|||||||
result.forEach((percent) => {
|
result.forEach((percent) => {
|
||||||
const bracket = new fabric.Rect({
|
const bracket = new fabric.Rect({
|
||||||
left: x2 - bracketLength / 3,
|
left: x2 - bracketLength / 3,
|
||||||
top: y2 - (rackLen / 10) * percent,
|
top: name === 'smartRack' ? y2 - rackLen * percent : y2 - (rackLen / 10) * percent,
|
||||||
fill: 'green',
|
fill: 'green',
|
||||||
name: 'bracket',
|
name: 'bracket',
|
||||||
parentId: rack.parentId,
|
parentId: rack.parentId,
|
||||||
@ -1337,8 +1487,49 @@ export const useTrestle = () => {
|
|||||||
return points.slice(0, 2)
|
return points.slice(0, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const calculateForApi = (moduleSurface) => {
|
const getCenterPoints = (moduleSurface) => {
|
||||||
const centerPoints = []
|
const centerPoints = []
|
||||||
|
let widthArr = []
|
||||||
|
let heightArr = []
|
||||||
|
const modules = moduleSurface.modules
|
||||||
|
modules.forEach((module, index) => {
|
||||||
|
module.tempIndex = index
|
||||||
|
const { x, y } = module.getCenterPoint()
|
||||||
|
const { width, height } = { ...module }
|
||||||
|
widthArr.push(width)
|
||||||
|
heightArr.push(height)
|
||||||
|
centerPoints.push({ x, y, width: Math.floor(width), height: Math.floor(height), index, moduleInfo: module.moduleInfo })
|
||||||
|
})
|
||||||
|
|
||||||
|
//widthArr 중복 제거 1이상 차이가 나지 않으면 같은 너비로 간주
|
||||||
|
widthArr = removeCloseValues(Array.from(new Set(widthArr)))
|
||||||
|
heightArr = removeCloseValues(Array.from(new Set(heightArr)))
|
||||||
|
|
||||||
|
centerPoints.forEach((centerPoint, index) => {
|
||||||
|
centerPoint.widthArr = [...widthArr]
|
||||||
|
|
||||||
|
centerPoint.heightArr = [...heightArr]
|
||||||
|
})
|
||||||
|
|
||||||
|
function removeCloseValues(arr, threshold = 1) {
|
||||||
|
arr.sort((a, b) => a - b) // 배열을 정렬
|
||||||
|
|
||||||
|
let result = []
|
||||||
|
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
if (i === 0 || Math.abs(arr[i] - arr[i - 1]) >= threshold) {
|
||||||
|
result.push(arr[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
return centerPoints
|
||||||
|
}
|
||||||
|
|
||||||
|
const calculateForApi = (moduleSurface) => {
|
||||||
|
const centerPoints = getCenterPoints(moduleSurface)
|
||||||
const direction = moduleSurface.direction
|
const direction = moduleSurface.direction
|
||||||
const modules = moduleSurface.modules
|
const modules = moduleSurface.modules
|
||||||
|
|
||||||
@ -1350,12 +1541,6 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
const maxX = 2 + horizontal * 3
|
const maxX = 2 + horizontal * 3
|
||||||
const maxY = 2 + vertical * 3
|
const maxY = 2 + vertical * 3
|
||||||
modules.forEach((module, index) => {
|
|
||||||
module.tempIndex = index
|
|
||||||
const { x, y } = module.getCenterPoint()
|
|
||||||
const { width, height } = { ...module }
|
|
||||||
centerPoints.push({ x, y, width: Math.floor(width), height: Math.floor(height), index })
|
|
||||||
})
|
|
||||||
|
|
||||||
if (centerPoints.length === 0) return
|
if (centerPoints.length === 0) return
|
||||||
|
|
||||||
@ -1382,7 +1567,7 @@ export const useTrestle = () => {
|
|||||||
let rightExposedHalfTopPoints = []
|
let rightExposedHalfTopPoints = []
|
||||||
|
|
||||||
centerPoints.forEach((centerPoint, index) => {
|
centerPoints.forEach((centerPoint, index) => {
|
||||||
let { x, y, width, height } = { ...centerPoint }
|
let { x, y, width, height, widthArr, heightArr } = { ...centerPoint }
|
||||||
// centerPoints중에 현재 centerPoint와 x값이 같고, y값이 y-height값과 같은 centerPoint가 있는지 확인
|
// centerPoints중에 현재 centerPoint와 x값이 같고, y값이 y-height값과 같은 centerPoint가 있는지 확인
|
||||||
let bottomCell
|
let bottomCell
|
||||||
let bottomLeftPoint
|
let bottomLeftPoint
|
||||||
@ -1392,28 +1577,29 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south':
|
case 'south':
|
||||||
width = width + horizontal
|
//widthArr의 값을 전부 더한 후 widthArr의 길이로 나누어 평균값을 구한다.
|
||||||
height = height + vertical
|
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
|
height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
||||||
bottomLeftPoint = { x: x - width / 2, y: y + height }
|
bottomLeftPoint = { x: x - width / 2, y: y + height }
|
||||||
bottomRightPoint = { x: x + width / 2, y: y + height }
|
bottomRightPoint = { x: x + width / 2, y: y + height }
|
||||||
break
|
break
|
||||||
case 'north':
|
case 'north':
|
||||||
width = width + horizontal
|
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
height = height + vertical
|
height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
||||||
bottomLeftPoint = { x: x + width / 2, y: y - height }
|
bottomLeftPoint = { x: x + width / 2, y: y - height }
|
||||||
bottomRightPoint = { x: x - width / 2, y: y - height }
|
bottomRightPoint = { x: x - width / 2, y: y - height }
|
||||||
break
|
break
|
||||||
case 'east':
|
case 'east':
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
width = width + horizontal
|
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
bottomLeftPoint = { x: x + width, y: y + height / 2 }
|
bottomLeftPoint = { x: x + width, y: y + height / 2 }
|
||||||
bottomRightPoint = { x: x + width, y: y - height / 2 }
|
bottomRightPoint = { x: x + width, y: y - height / 2 }
|
||||||
break
|
break
|
||||||
case 'west':
|
case 'west':
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
width = width + horizontal
|
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
bottomLeftPoint = { x: x - width, y: y - height / 2 }
|
bottomLeftPoint = { x: x - width, y: y - height / 2 }
|
||||||
bottomRightPoint = { x: x - width, y: y + height / 2 }
|
bottomRightPoint = { x: x - width, y: y + height / 2 }
|
||||||
break
|
break
|
||||||
@ -1870,16 +2056,16 @@ export const useTrestle = () => {
|
|||||||
const { direction, modules } = surface
|
const { direction, modules } = surface
|
||||||
let { rackYn, cvrPlvrYn, moduleIntvlHor, moduleIntvlVer, rackQty, lessSupFitQty } = surface.trestleDetail
|
let { rackYn, cvrPlvrYn, moduleIntvlHor, moduleIntvlVer, rackQty, lessSupFitQty } = surface.trestleDetail
|
||||||
|
|
||||||
const centerPoints = modules.map((module) => {
|
const centerPoints = getCenterPoints(surface)
|
||||||
return module.getCenterPoint()
|
|
||||||
})
|
|
||||||
|
|
||||||
const horizontal = ['south', 'north'].includes(direction) ? moduleIntvlHor : moduleIntvlVer
|
const horizontal = ['south', 'north'].includes(direction) ? moduleIntvlHor : moduleIntvlVer
|
||||||
|
|
||||||
const vertical = ['south', 'north'].includes(direction) ? moduleIntvlVer : moduleIntvlHor
|
const vertical = ['south', 'north'].includes(direction) ? moduleIntvlVer : moduleIntvlHor
|
||||||
const maxX = 2 + horizontal * 3
|
const maxX = 2 + horizontal * 3
|
||||||
const maxY = 2 + vertical * 3
|
const maxY = 2 + vertical * 3
|
||||||
let { width, height } = { ...module }
|
let { widthArr, heightArr } = centerPoints[0]
|
||||||
|
let width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length
|
||||||
|
let height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length
|
||||||
let { x, y } = { ...module.getCenterPoint() }
|
let { x, y } = { ...module.getCenterPoint() }
|
||||||
|
|
||||||
let halfBottomLeftPoint
|
let halfBottomLeftPoint
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user