This commit is contained in:
Minsiki 2025-01-31 17:13:11 +09:00
commit 7a2eee833e
2 changed files with 152 additions and 42 deletions

View File

@ -43,7 +43,7 @@ export default function CircuitTrestleSetting({ id }) {
const [circuitAllocationType, setCircuitAllocationType] = useState(1) const [circuitAllocationType, setCircuitAllocationType] = useState(1)
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext) const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
const selectedModules = useRecoilValue(selectedModuleState) const selectedModules = useRecoilValue(selectedModuleState)
const { getPcsAutoRecommendList } = useMasterController() const { getPcsAutoRecommendList, getPcsVoltageChk } = useMasterController()
useEffect(() => { useEffect(() => {
if (!managementState) { if (!managementState) {
@ -75,32 +75,48 @@ export default function CircuitTrestleSetting({ id }) {
pcsItemList: getPcsItemList(), pcsItemList: getPcsItemList(),
} }
getPcsAutoRecommendList(params).then((res) => { if (selectedModels.length === 0) {
if (res.data?.pcsItemList) { getPcsAutoRecommendList(params).then((res) => {
setModels( if (res.data?.pcsItemList) {
res.data.pcsItemList.map((model) => { const itemList = models.filter((model) => {
return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId)
})
const selectedModels = itemList.map((model) => {
return { return {
...model, ...model,
id: uuidv4(), id: uuidv4(),
} }
}), })
) const pcsVoltageChkParams = {
setTabNum(2) ...getOptYn(),
} else { useModuleItemList: getUseModuleItemList(),
// roofSurfaceList: getRoofSurfaceList(),
if (res.result.resultCode === 'E') { pcsItemList: getPcsItemList(),
swalFire({ }
title: res.result.resultMsg, setSelectedModels(selectedModels)
type: 'alert', getPcsVoltageChk(pcsVoltageChkParams).then((res) => {
setTabNum(2)
}) })
} else { } else {
swalFire({ //
title: '파워컨디셔너를 추가해 주세요.', if (res.result.resultCode === 'E') {
type: 'alert', swalFire({
}) title: res.result.resultMsg,
type: 'alert',
})
} else {
swalFire({
title: '파워컨디셔너를 추가해 주세요.',
type: 'alert',
})
}
} }
} })
}) } else {
getPcsVoltageChk(params).then((res) => {
setTabNum(2)
})
}
} }
const getOptYn = () => { const getOptYn = () => {
@ -135,6 +151,7 @@ export default function CircuitTrestleSetting({ id }) {
.getObjects() .getObjects()
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) .filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
.map((obj) => { .map((obj) => {
getModuleList(obj)
return { return {
roofSurfaceId: obj.id, roofSurfaceId: obj.id,
roofSurface: canvas roofSurface: canvas
@ -142,7 +159,7 @@ export default function CircuitTrestleSetting({ id }) {
.filter((o) => o.id === obj.parentId)[0] .filter((o) => o.id === obj.parentId)[0]
.directionText.replace(/[0-9]/g, ''), .directionText.replace(/[0-9]/g, ''),
roofSurfaceIncl: canvas.getObjects().filter((o) => o.id === obj.parentId)[0].roofMaterial.pitch, roofSurfaceIncl: canvas.getObjects().filter((o) => o.id === obj.parentId)[0].roofMaterial.pitch,
moduleList: obj.modules.map((module) => { moduleList: getModuleList(obj).map((module) => {
return { return {
itemId: module.moduleInfo.itemId, itemId: module.moduleInfo.itemId,
circuit: module.circuitNumber ? module.circuitNumber : null, 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 = () => { const onAutoAllocation = () => {
let moduleStdQty = 0 let moduleStdQty = 0
let moduleMaxQty = 0 let moduleMaxQty = 0
@ -168,19 +258,19 @@ export default function CircuitTrestleSetting({ id }) {
return acc + parseInt(model.moduleMaxQty) return acc + parseInt(model.moduleMaxQty)
}, 0) }, 0)
} }
const target = pcsCheck.max ? moduleMaxQty : moduleStdQty // const target = pcsCheck.max ? moduleMaxQty : moduleStdQty
const placementModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE) // const placementModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE)
if (placementModules.length > target) { // if (placementModules.length > target) {
swalFire({ // swalFire({
title: '배치가능 매수를 초과합니다. 파워컨디셔너를 다시 선택해 주세요.', // title: ' . .',
type: 'alert', // type: 'alert',
}) // })
return // return
} // }
// setAllocationType(ALLOCATION_TYPE.AUTO) // setAllocationType(ALLOCATION_TYPE.AUTO)
setTabNum(2) // setTabNum(2)
} }
const onPassivityAllocation = () => { const onPassivityAllocation = () => {
@ -197,14 +287,20 @@ export default function CircuitTrestleSetting({ id }) {
const itemList = models.filter((model) => { const itemList = models.filter((model) => {
return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId) return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId)
}) })
setSelectedModels( const selectedModels = itemList.map((model) => {
itemList.map((model) => { return {
return { ...model,
...model, id: uuidv4(),
id: uuidv4(), }
} })
}), const PcsVoltageChkParams = {
) ...getOptYn(),
useModuleItemList: getUseModuleItemList(),
roofSurfaceList: getRoofSurfaceList(),
pcsItemList: getPcsItemList(),
}
setSelectedModels(selectedModels)
getPcsVoltageChk(PcsVoltageChkParams).then((res) => {})
} else { } else {
swalFire({ swalFire({
title: '파워컨디셔너를 추가해 주세요.', 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 승압설정 정보 조회 * PCS 승압설정 정보 조회
* @param {Max접속(과적)여부} maxConnYn * @param {Max접속(과적)여부} maxConnYn
@ -195,10 +211,7 @@ export function useMasterController() {
pcsItemList: params2.pcsItemList, pcsItemList: params2.pcsItemList,
} }
console.log('🚀 ~ getPcsVoltageStepUpList ~ params >>>>> :', params)
return await post({ url: '/api/v1/master/getPcsVoltageStepUpList', data: params }).then((res) => { return await post({ url: '/api/v1/master/getPcsVoltageStepUpList', data: params }).then((res) => {
console.log('🚀🚀 ~ getPcsVoltageStepUpList ~ res:', res)
return res return res
}) })
} }
@ -212,6 +225,7 @@ export function useMasterController() {
getPcsMakerList, getPcsMakerList,
getPcsModelList, getPcsModelList,
getPcsAutoRecommendList, getPcsAutoRecommendList,
getPcsVoltageChk,
getPcsManualConfChk, getPcsManualConfChk,
getPcsVoltageStepUpList, getPcsVoltageStepUpList,
} }