From a11867a49d48e2a377e465040023fdbea686d8dd Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 31 Jan 2025 15:56:52 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=EB=8B=A8=EC=88=98=20=EA=B3=84=EC=82=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useTrestle.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 5730f574..ccc8e82f 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -182,6 +182,8 @@ export const useTrestle = () => { const horizontal = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlHor : surface.trestleDetail.moduleIntvlVer const vertical = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlVer : surface.trestleDetail.moduleIntvlHor + + let mostRowsModule = 0 // 가장 많은 모듈의 줄 수 // 가대 설치를 위한 가장 아래 모듈로부터 위로 몇단인지 계산 // 오른쪽,왼쪽 둘 다 아래에 아무것도 없는, 처마 커버를 필요로 하는 모듈 exposedBottomModules.forEach((module) => { @@ -299,7 +301,7 @@ export const useTrestle = () => { return rack.value.moduleRows === centerRows })?.value.racks - moduleRowsTotCnt = Math.max(leftRows, rightRows, centerRows) + mostRowsModule = Math.max(leftRows, rightRows, centerRows, mostRowsModule) if (rackYn === 'Y') { drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn) @@ -361,7 +363,7 @@ export const useTrestle = () => { const leftRacks = rackInfos.find((rack) => { return rack.value.moduleRows === leftRows })?.value.racks - moduleRowsTotCnt = Math.max(leftRows, moduleRowsTotCnt) + mostRowsModule = Math.max(leftRows, mostRowsModule) if (rackYn === 'Y') { drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn) } @@ -415,7 +417,7 @@ export const useTrestle = () => { return rack.value.moduleRows === rightRows })?.value.racks - moduleRowsTotCnt = Math.max(rightRows, moduleRowsTotCnt) + mostRowsModule = Math.max(rightRows, mostRowsModule) // 해당 rack으로 그려준다. if (rackYn === 'Y') { drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn) @@ -424,7 +426,7 @@ export const useTrestle = () => { module.set({ rightRows }) }) - surface.set({ moduleRowsTotCnt }) + surface.set({ moduleRowsTotCnt: mostRowsModule }) if (rackYn === 'N') { // rack이 없을경우 @@ -1642,6 +1644,7 @@ export const useTrestle = () => { if (cvrPlvrYn === 'Y') { moduleRowResultData.eavesHalfCnt++ if (bottomLeftModule || bottomRightModule || halfBottomLeftModule || halfBottomRightModule) { + //처마커버 한개 노출 추가 moduleRowResultData.exposedSideEavesCnt++ } } @@ -1649,10 +1652,10 @@ export const useTrestle = () => { moduleRowResultData.exposedBottomCnt++ if (isEaveBar) { moduleRowResultData.eavesCnt++ - } - - if (!(leftModule && rightModule)) { - moduleRowResultData.exposedSideEavesCnt++ + if ((rightModule && !leftModule) || (!rightModule && leftModule)) { + // 둘중 하나가 없는경우는 처마커버 노출 추가 + moduleRowResultData.exposedSideEavesCnt++ + } } } } From 764d9f2475d78fd842f931be54663998cc630fae Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 31 Jan 2025 15:57:31 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=EB=8B=A8=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useTrestle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index ccc8e82f..968f782d 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -183,7 +183,7 @@ export const useTrestle = () => { const vertical = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlVer : surface.trestleDetail.moduleIntvlHor - let mostRowsModule = 0 // 가장 많은 모듈의 줄 수 + let mostRowsModule = 0 // 모듈 최대 단 수 // 가대 설치를 위한 가장 아래 모듈로부터 위로 몇단인지 계산 // 오른쪽,왼쪽 둘 다 아래에 아무것도 없는, 처마 커버를 필요로 하는 모듈 exposedBottomModules.forEach((module) => { From 7a2a09689fe0532354ef54b802ccaf98c3729da8 Mon Sep 17 00:00:00 2001 From: Minsiki Date: Fri, 31 Jan 2025 17:12:09 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=EC=9E=90=EB=8F=99=20=ED=95=A0=EB=8B=B9=20?= =?UTF-8?q?=EC=8B=9C=20=EB=AA=A8=EB=93=88=20=EC=88=9C=EC=84=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circuitTrestle/CircuitTrestleSetting.jsx | 174 ++++++++++++++---- src/hooks/common/useMasterController.js | 20 +- 2 files changed, 152 insertions(+), 42 deletions(-) diff --git a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx index a0d2b34f..8c9d31af 100644 --- a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx @@ -43,7 +43,7 @@ export default function CircuitTrestleSetting({ id }) { const [circuitAllocationType, setCircuitAllocationType] = useState(1) const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext) const selectedModules = useRecoilValue(selectedModuleState) - const { getPcsAutoRecommendList } = useMasterController() + const { getPcsAutoRecommendList, getPcsVoltageChk } = useMasterController() useEffect(() => { if (!managementState) { @@ -75,32 +75,48 @@ export default function CircuitTrestleSetting({ id }) { pcsItemList: getPcsItemList(), } - getPcsAutoRecommendList(params).then((res) => { - if (res.data?.pcsItemList) { - setModels( - res.data.pcsItemList.map((model) => { + if (selectedModels.length === 0) { + getPcsAutoRecommendList(params).then((res) => { + if (res.data?.pcsItemList) { + const itemList = models.filter((model) => { + return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId) + }) + const selectedModels = itemList.map((model) => { return { ...model, id: uuidv4(), } - }), - ) - setTabNum(2) - } else { - // 데이터가 없는 경우 오류 메시지 확인 필요 - if (res.result.resultCode === 'E') { - swalFire({ - title: res.result.resultMsg, - type: 'alert', + }) + const pcsVoltageChkParams = { + ...getOptYn(), + useModuleItemList: getUseModuleItemList(), + roofSurfaceList: getRoofSurfaceList(), + pcsItemList: getPcsItemList(), + } + setSelectedModels(selectedModels) + getPcsVoltageChk(pcsVoltageChkParams).then((res) => { + setTabNum(2) }) } else { - swalFire({ - title: '파워컨디셔너를 추가해 주세요.', - type: 'alert', - }) + // 데이터가 없는 경우 오류 메시지 확인 필요 + if (res.result.resultCode === 'E') { + swalFire({ + title: res.result.resultMsg, + type: 'alert', + }) + } else { + swalFire({ + title: '파워컨디셔너를 추가해 주세요.', + type: 'alert', + }) + } } - } - }) + }) + } else { + getPcsVoltageChk(params).then((res) => { + setTabNum(2) + }) + } } const getOptYn = () => { @@ -135,6 +151,7 @@ export default function CircuitTrestleSetting({ id }) { .getObjects() .filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) .map((obj) => { + getModuleList(obj) return { roofSurfaceId: obj.id, roofSurface: canvas @@ -142,7 +159,7 @@ export default function CircuitTrestleSetting({ id }) { .filter((o) => o.id === obj.parentId)[0] .directionText.replace(/[0-9]/g, ''), roofSurfaceIncl: canvas.getObjects().filter((o) => o.id === obj.parentId)[0].roofMaterial.pitch, - moduleList: obj.modules.map((module) => { + moduleList: getModuleList(obj).map((module) => { return { itemId: module.moduleInfo.itemId, circuit: module.circuitNumber ? module.circuitNumber : null, @@ -153,6 +170,79 @@ export default function CircuitTrestleSetting({ id }) { }) } + const getModuleList = (surface) => { + let moduleList = [] + let [xObj, yObj] = [{}, {}] + let [xPoints, yPoints] = [[], []] + surface.modules.forEach((module) => { + if (!xObj[module.left]) { + xObj[module.left] = module.left + xPoints.push(module.left) + } + if (!yObj[module.top]) { + yObj[module.top] = module.top + yPoints.push(module.top) + } + }) + switch (surface.direction) { + case 'south': + xPoints.sort((a, b) => a - b) + yPoints.sort((a, b) => b - a) + yPoints.forEach((y, index) => { + let temp = surface.modules.filter((m) => m.top === y) + if (index % 2 === 0) { + temp.sort((a, b) => a.left - b.left) + } else { + temp.sort((a, b) => b.left - a.left) + } + moduleList = [...moduleList, ...temp] + }) + break + case 'north': + xPoints.sort((a, b) => b - a) + yPoints.sort((a, b) => a - b) + yPoints.forEach((y, index) => { + let temp = surface.modules.filter((m) => m.top === y) + if (index % 2 === 0) { + temp.sort((a, b) => b.left - a.left) + } else { + temp.sort((a, b) => a.left - b.left) + } + moduleList = [...moduleList, ...temp] + }) + break + case 'west': + xPoints.sort((a, b) => a - b) + yPoints.sort((a, b) => a - b) + xPoints.forEach((x, index) => { + let temp = surface.modules.filter((m) => m.left === x) + if (index % 2 === 0) { + temp.sort((a, b) => a.top - b.top) + } else { + temp.sort((a, b) => b.top - a.top) + } + moduleList = [...moduleList, ...temp] + }) + break + case 'east': + xPoints.sort((a, b) => b - a) + yPoints.sort((a, b) => b - a) + xPoints.forEach((x, index) => { + let temp = surface.modules.filter((m) => m.left === x) + if (index % 2 === 0) { + temp.sort((a, b) => b.top - a.top) + } else { + temp.sort((a, b) => a.top - b.top) + } + moduleList = [...moduleList, ...temp] + }) + break + default: + return [] + } + return moduleList + } + const onAutoAllocation = () => { let moduleStdQty = 0 let moduleMaxQty = 0 @@ -168,19 +258,19 @@ export default function CircuitTrestleSetting({ id }) { return acc + parseInt(model.moduleMaxQty) }, 0) } - const target = pcsCheck.max ? moduleMaxQty : moduleStdQty - const placementModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE) + // const target = pcsCheck.max ? moduleMaxQty : moduleStdQty + // const placementModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE) - if (placementModules.length > target) { - swalFire({ - title: '배치가능 매수를 초과합니다. 파워컨디셔너를 다시 선택해 주세요.', - type: 'alert', - }) - return - } + // if (placementModules.length > target) { + // swalFire({ + // title: '배치가능 매수를 초과합니다. 파워컨디셔너를 다시 선택해 주세요.', + // type: 'alert', + // }) + // return + // } // setAllocationType(ALLOCATION_TYPE.AUTO) - setTabNum(2) + // setTabNum(2) } const onPassivityAllocation = () => { @@ -197,14 +287,20 @@ export default function CircuitTrestleSetting({ id }) { const itemList = models.filter((model) => { return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId) }) - setSelectedModels( - itemList.map((model) => { - return { - ...model, - id: uuidv4(), - } - }), - ) + const selectedModels = itemList.map((model) => { + return { + ...model, + id: uuidv4(), + } + }) + const PcsVoltageChkParams = { + ...getOptYn(), + useModuleItemList: getUseModuleItemList(), + roofSurfaceList: getRoofSurfaceList(), + pcsItemList: getPcsItemList(), + } + setSelectedModels(selectedModels) + getPcsVoltageChk(PcsVoltageChkParams).then((res) => {}) } else { swalFire({ title: '파워컨디셔너를 추가해 주세요.', diff --git a/src/hooks/common/useMasterController.js b/src/hooks/common/useMasterController.js index 554b6a4a..ef31962f 100644 --- a/src/hooks/common/useMasterController.js +++ b/src/hooks/common/useMasterController.js @@ -173,6 +173,22 @@ export function useMasterController() { }) } + /** + * PCS로 회로 구성 가능 여부 체크 + * @param {Max접속(과적)여부} maxConnYn + * @param {동일회로도여부} smpCirYn + * @param {한랭지여부} coldZoneYn + * @param {사용된 모듈 아이템 List} useModuleItemList + * @param {지붕면별 목록} roofSurfaceList + * @param {PCS 제품 목록} pcsItemList + * @returns + */ + const getPcsVoltageChk = async (params = null) => { + return await post({ url: '/api/v1/master/getPcsVoltageChk', data: params }).then((res) => { + return res + }) + } + /** * PCS 승압설정 정보 조회 * @param {Max접속(과적)여부} maxConnYn @@ -195,10 +211,7 @@ export function useMasterController() { pcsItemList: params2.pcsItemList, } - console.log('🚀 ~ getPcsVoltageStepUpList ~ params >>>>> :', params) - return await post({ url: '/api/v1/master/getPcsVoltageStepUpList', data: params }).then((res) => { - console.log('🚀🚀 ~ getPcsVoltageStepUpList ~ res:', res) return res }) } @@ -212,6 +225,7 @@ export function useMasterController() { getPcsMakerList, getPcsModelList, getPcsAutoRecommendList, + getPcsVoltageChk, getPcsManualConfChk, getPcsVoltageStepUpList, }