Merge branch 'dev' into dev-yj

This commit is contained in:
yjnoh 2025-01-31 18:29:07 +09:00
commit 401d9c4104
3 changed files with 163 additions and 50 deletions

View File

@ -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: '파워컨디셔너를 추가해 주세요.',

View File

@ -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,
}

View File

@ -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++
}
}
}
}