가대 설치 후 파라미터 생성 작업중
This commit is contained in:
parent
749ed58fa9
commit
793d127b6e
@ -177,6 +177,8 @@ export const SAVE_KEY = [
|
||||
'moduleRowsTotCnt',
|
||||
'seq',
|
||||
'smartRackId',
|
||||
'quotationParam',
|
||||
'pcses',
|
||||
]
|
||||
|
||||
export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype]
|
||||
|
||||
@ -292,8 +292,8 @@ export default function DotLineGrid(props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-foot modal-handle"></div>
|
||||
</div>
|
||||
<div className="modal-foot modal-handle"></div>
|
||||
</WithDraggable>
|
||||
)
|
||||
}
|
||||
|
||||
@ -216,6 +216,12 @@ export function useMasterController() {
|
||||
})
|
||||
}
|
||||
|
||||
const getQuotationItem = async (params) => {
|
||||
return await post({ url: '/api/v1/master/getQuotationItem', data: params }).then((res) => {
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
getRoofMaterialList,
|
||||
getModuleTypeItemList,
|
||||
@ -228,5 +234,6 @@ export function useMasterController() {
|
||||
getPcsVoltageChk,
|
||||
getPcsManualConfChk,
|
||||
getPcsVoltageStepUpList,
|
||||
getQuotationItem,
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,11 +4,13 @@ import { POLYGON_TYPE } from '@/common/common'
|
||||
import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
|
||||
import { getDegreeByChon, getTrestleLength } from '@/util/canvas-util'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { useMasterController } from '@/hooks/common/useMasterController'
|
||||
|
||||
// 회로 및 가대설정
|
||||
export const useTrestle = () => {
|
||||
const canvas = useRecoilValue(canvasState)
|
||||
const moduleSelectionData = useRecoilValue(moduleSelectionDataState) //다음으로 넘어가는 최종 데이터
|
||||
const { getQuotationItem } = useMasterController()
|
||||
|
||||
const apply = () => {
|
||||
//처마력바가 체크되어 있는 경우 exposedBottomPoints를 이용해 처마력바 그려줘야함.
|
||||
@ -17,7 +19,7 @@ export const useTrestle = () => {
|
||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
// 기존 eaveBar를 삭제
|
||||
canvas.getObjects().forEach((obj) => {
|
||||
if (obj.name === 'eaveBar' || obj.name === 'rack') {
|
||||
if (obj.name === 'eaveBar' || obj.name === 'rack' || obj.name === 'halfEaveBar' || obj.name === 'smartRack') {
|
||||
canvas.remove(obj)
|
||||
}
|
||||
})
|
||||
@ -96,7 +98,7 @@ export const useTrestle = () => {
|
||||
|
||||
canvas
|
||||
.getObjects()
|
||||
.filter((obj) => ['eaveBar', 'halfEaveBar'].includes(obj.name) && obj.parent === surface)
|
||||
.filter((obj) => ['eaveBar', 'halfEaveBar'].includes(obj.name) && obj.parentId === surface.id)
|
||||
.forEach((obj) => {
|
||||
canvas.remove(obj)
|
||||
})
|
||||
@ -435,7 +437,18 @@ export const useTrestle = () => {
|
||||
installBracket(surface)
|
||||
}
|
||||
|
||||
console.log(getTrestleParams(surface))
|
||||
const quotationParam = getTrestleParams(surface)
|
||||
|
||||
surface.set({ quotationParam })
|
||||
getQuoationItems()
|
||||
})
|
||||
}
|
||||
|
||||
const getQuoationItems = () => {
|
||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
const params = { trestles: surfaces.map((surface) => surface.quotationParam) }
|
||||
getQuotationItem(params).then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
|
||||
@ -633,9 +646,9 @@ export const useTrestle = () => {
|
||||
smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => {
|
||||
rackLength = getTrestleLength(setRackTpLen, degree) / 10
|
||||
if (setRackTpCd === 'RACK') {
|
||||
const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], {
|
||||
const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY - rackLength], {
|
||||
name: 'smartRack',
|
||||
stroke: 'blue',
|
||||
stroke: 'red',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
shadow: {
|
||||
@ -706,7 +719,7 @@ export const useTrestle = () => {
|
||||
if (setRackTpCd === 'RACK') {
|
||||
const rack = new fabric.Line([startPointX, startPointY, startPointX - rackLength, startPointY], {
|
||||
name: 'smartRack',
|
||||
stroke: 'blue',
|
||||
stroke: 'red',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
shadow: {
|
||||
@ -775,7 +788,7 @@ export const useTrestle = () => {
|
||||
if (setRackTpCd === 'RACK') {
|
||||
const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], {
|
||||
name: 'smartRack',
|
||||
stroke: 'blue',
|
||||
stroke: 'red',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
shadow: {
|
||||
@ -840,9 +853,9 @@ export const useTrestle = () => {
|
||||
smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => {
|
||||
rackLength = getTrestleLength(setRackTpLen, degree) / 10
|
||||
if (setRackTpCd === 'RACK') {
|
||||
const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], {
|
||||
const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY + rackLength], {
|
||||
name: 'smartRack',
|
||||
stroke: 'blue',
|
||||
stroke: 'red',
|
||||
strokeWidth: 4,
|
||||
selectable: false,
|
||||
shadow: {
|
||||
@ -906,7 +919,7 @@ export const useTrestle = () => {
|
||||
modules.forEach((module) => {
|
||||
canvas
|
||||
.getObjects()
|
||||
.filter((obj) => obj.name === 'rack')
|
||||
.filter((obj) => obj.name === 'rack' || obj.name === 'smartRack')
|
||||
.forEach((rack) => {
|
||||
if (rack.parentId === module.id) {
|
||||
canvas.remove(canvas.getObjects().filter((obj) => obj.name === 'bracket' && obj.parentId === rack.id))
|
||||
@ -1171,7 +1184,7 @@ export const useTrestle = () => {
|
||||
|
||||
const getBracketPoints = (n, percent) => {
|
||||
if (n < 2) {
|
||||
throw new Error('Number of points must be at least 2')
|
||||
return []
|
||||
}
|
||||
|
||||
const points = []
|
||||
@ -1479,6 +1492,7 @@ export const useTrestle = () => {
|
||||
return groups
|
||||
}
|
||||
|
||||
// 견적서 아이템 조회 api parameter 생성
|
||||
const getTrestleParams = (surface) => {
|
||||
const result = calculateForApi(surface)
|
||||
|
||||
@ -1505,8 +1519,24 @@ export const useTrestle = () => {
|
||||
rackRows: rack.rackRowsCd,
|
||||
}
|
||||
})
|
||||
const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId)
|
||||
const roofMaterialIndex = parent.roofMaterial.index
|
||||
const moduleSelection = moduleSelectionData?.roofConstructions?.find((construction) => construction.roofIndex === roofMaterialIndex)
|
||||
const { common, module } = moduleSelectionData
|
||||
|
||||
// const { constTp } = construction
|
||||
let { cvrPlvrYn } = surface.trestleDetail
|
||||
const { trestleMkrCd, constMthdCd, roofBaseCd } = moduleSelection.trestle
|
||||
const { illuminationTp, instHt, stdSnowLd, stdWindSpeed } = common
|
||||
const { constTp } = moduleSelection.construction
|
||||
const { addRoof } = moduleSelection
|
||||
|
||||
return {
|
||||
moduleTpCd: module.itemTp,
|
||||
roofMatlCd: parent.roofMaterial.roofMatlCd,
|
||||
mixMatlNo: module.mixMatlNo,
|
||||
raftBaseCd: addRoof.raft,
|
||||
roofPitch: addRoof.roofPchBase,
|
||||
exposedLowerBottomTotCnt: result.exposedBottom, // 노출 최하면 갯수
|
||||
exposedHalfBottomTotCnt: result.exposedHalfBottom, // 노출 반하면 갯수
|
||||
exposedTopTotCnt: result.exposedTop, // 노출 상면 총 수
|
||||
@ -1521,9 +1551,56 @@ export const useTrestle = () => {
|
||||
rackTotCnt: rackList.length ?? 0 + smartRackGroup.length ?? 0,
|
||||
rackFittingCnt: bracketList.length,
|
||||
moduleRows: getMostLeftModules(surface),
|
||||
cvrYn: moduleSelection.construction.setupCover ? 'Y' : 'N',
|
||||
snowGuardYn: moduleSelection.construction.setupSnowCover ? 'Y' : 'N',
|
||||
plvrYn: cvrPlvrYn,
|
||||
modules: getModules(surface),
|
||||
pcses: surface.pcses ?? [],
|
||||
trestleMkrCd,
|
||||
constMthdCd,
|
||||
roofBaseCd,
|
||||
illuminationTp,
|
||||
instHt,
|
||||
stdSnowLd,
|
||||
stdWindSpeed,
|
||||
constTp,
|
||||
}
|
||||
}
|
||||
|
||||
const getModules = (surface) => {
|
||||
const { modules } = surface
|
||||
|
||||
const params = modules.map((module, index) => {
|
||||
return {
|
||||
moduleTpCd: module.moduleInfo.itemTp,
|
||||
moduleItemId: module.moduleInfo.itemId,
|
||||
}
|
||||
})
|
||||
|
||||
//params를 moduleTpCd, moduleItemId로 그룹화 하면서 cnt를 계산
|
||||
const groupedParams = params.reduce((acc, cur) => {
|
||||
const key = `${cur.moduleTpCd}-${cur.moduleItemId}`
|
||||
if (!acc[key]) {
|
||||
acc[key] = {
|
||||
moduleTpCd: cur.moduleTpCd,
|
||||
moduleItemId: cur.moduleItemId,
|
||||
cnt: 0,
|
||||
}
|
||||
}
|
||||
acc[key].cnt++
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
// map 형태의 데이터를 배열로 변환
|
||||
return Object.values(groupedParams).map((groupedParam, index) => {
|
||||
return {
|
||||
moduleTpCd: groupedParam.moduleTpCd,
|
||||
moduleItemId: groupedParam.moduleItemId,
|
||||
moduleCnt: groupedParam.cnt,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 가장 왼쪽에 있는 모듈을 기준으로 같은 단에 있는 모듈들 파라미터 생성
|
||||
const getMostLeftModules = (surface) => {
|
||||
const { direction, modules } = surface
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user