모듈 이동 후 수동배치 시 버그 수정
육지붕일 경우 수동배치시 moduleInfo 설정 추가
This commit is contained in:
parent
aeca8261a8
commit
156256c4ea
@ -730,7 +730,7 @@ export function useModuleBasicSetting(tabNum) {
|
||||
tempModule.setCoords() //좌표 재정렬
|
||||
if (turf.booleanContains(turfPolygon, tempTurfModule) || turf.booleanWithin(tempTurfModule, turfPolygon)) {
|
||||
//마우스 클릭시 set으로 해당 위치에 셀을 넣음
|
||||
const isOverlap = manualDrawModules.some((module) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(module))) //겹치는지 확인
|
||||
const isOverlap = manualDrawModules.some((module) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(module, true))) //겹치는지 확인
|
||||
if (!isOverlap) {
|
||||
canvas?.remove(tempModule)
|
||||
|
||||
@ -2205,12 +2205,13 @@ export function useModuleBasicSetting(tabNum) {
|
||||
|
||||
if (turf.booleanWithin(tempTurfModule, turfPolygon)) {
|
||||
//마우스 클릭시 set으로 해당 위치에 셀을 넣음
|
||||
const isOverlap = manualDrawModules.some((module) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(module))) //겹치는지 확인
|
||||
const isOverlap = manualDrawModules.some((module) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(module, true))) //겹치는지 확인
|
||||
if (!isOverlap) {
|
||||
moduleOptions.surfaceId = trestlePolygon.id
|
||||
let manualModule = new QPolygon(tempModule.points, { ...moduleOptions, moduleInfo: checkedModule[0] })
|
||||
canvas?.add(manualModule)
|
||||
manualDrawModules.push(tempModule)
|
||||
manualDrawModules.push(manualModule)
|
||||
setModuleStatisticsData()
|
||||
} else {
|
||||
swalFire({ text: getMessage('module.place.overlab') })
|
||||
}
|
||||
@ -2626,62 +2627,6 @@ export function useModuleBasicSetting(tabNum) {
|
||||
return isDisjoint
|
||||
}
|
||||
|
||||
const getModuleStatistics = () => {
|
||||
const surfaces = canvas.getObjects().filter((obj) => POLYGON_TYPE.MODULE_SETUP_SURFACE === obj.name)
|
||||
// console.log('🚀 ~ getModuleStatistics ~ surfaces:', surfaces)
|
||||
let totalWpout = 0
|
||||
let moduleInfo = {}
|
||||
const rows = surfaces.map((surface) => {
|
||||
let wpOut = 0
|
||||
moduleInfo = {}
|
||||
surface.modules.forEach((module) => {
|
||||
if (!moduleInfo[module.moduleInfo.itemId]) {
|
||||
moduleInfo[module.moduleInfo.itemId] = { name: module.moduleInfo.itemNm, amount: 0, id: module.moduleInfo.itemId }
|
||||
}
|
||||
wpOut += +module.moduleInfo.wpOut
|
||||
|
||||
moduleInfo[module.moduleInfo.itemId].amount++
|
||||
})
|
||||
totalWpout += wpOut
|
||||
// console.log('🚀 ~ moduleData.rows=surfaces.map ~ module:', module)
|
||||
const rowObject = {}
|
||||
Object.keys(moduleInfo).forEach((key) => {
|
||||
rowObject[key] = moduleInfo[key].amount
|
||||
})
|
||||
return {
|
||||
...rowObject, // 총 발전량 = 발전량 * 모듈 개수
|
||||
...surface,
|
||||
name: canvas.getObjects().filter((obj) => obj.id === surface.parentId)[0].directionText, // 지붕면
|
||||
// powerGeneration: wpOut.toLocaleString('ko-KR', { maximumFractionDigits: 4 }),
|
||||
wpOut: (wpOut / 1000).toFixed(3),
|
||||
}
|
||||
})
|
||||
|
||||
// console.log('🚀 ~ getModuleStatistics ~ rows:', rows)
|
||||
// console.log('🚀 ~ getModuleStatistics ~ moduleInfo:', moduleInfo)
|
||||
const header = [
|
||||
{ name: getMessage('modal.panel.batch.statistic.roof.shape'), prop: 'name' },
|
||||
...Object.keys(moduleInfo).map((key) => {
|
||||
return { name: moduleInfo[key].name, prop: key }
|
||||
}),
|
||||
{ name: `${getMessage('modal.panel.batch.statistic.power.generation.amount')}(kW)`, prop: 'wpOut' },
|
||||
]
|
||||
let footer = [getMessage('modal.panel.batch.statistic.total')]
|
||||
let footerData = {}
|
||||
rows.forEach((row) => {
|
||||
Object.keys(moduleInfo).map((key) => {
|
||||
if (!footerData[key]) footerData[key] = 0
|
||||
footerData[key] += row[key]
|
||||
})
|
||||
})
|
||||
Object.keys(footerData).forEach((key) => {
|
||||
footer.push(footerData[key])
|
||||
})
|
||||
footer.push((totalWpout / 1000).toFixed(3))
|
||||
// console.log({ header: header, rows, footer: footer })
|
||||
setModuleStatistics({ header: header, rows, footer: footer })
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈의 너비와 높이를 계산하는 함수
|
||||
* @param {object} maxLengthLine 최대 길이 라인
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user