Compare commits

..

No commits in common. "e0da5e67940ee176cf49bc8838051c9cbb76fe09" and "f26be9c1a43619a1961fe73dfe5afeea9c09a733" have entirely different histories.

5 changed files with 31 additions and 79 deletions

View File

@ -26,7 +26,6 @@
"framer-motion": "^11.2.13", "framer-motion": "^11.2.13",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"iron-session": "^8.0.2", "iron-session": "^8.0.2",
"jimp": "^1.6.0",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"mathjs": "^13.0.2", "mathjs": "^13.0.2",
"mssql": "^11.0.1", "mssql": "^11.0.1",

View File

@ -1,8 +1,7 @@
import { NextResponse } from 'next/server' import { NextResponse } from 'next/server'
import { DeleteObjectCommand, GetObjectCommand, PutObjectCommand, S3Client } from '@aws-sdk/client-s3' import { S3Client, PutObjectCommand, DeleteObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3'
import sharp from 'sharp'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { Jimp } from 'jimp'
const Bucket = process.env.AMPLIFY_BUCKET const Bucket = process.env.AMPLIFY_BUCKET
const s3 = new S3Client({ const s3 = new S3Client({
region: process.env.AWS_REGION, region: process.env.AWS_REGION,
@ -24,6 +23,8 @@ const checkArea = (obj) => {
const cropImage = async (Key, width, height, left, top) => { const cropImage = async (Key, width, height, left, top) => {
try { try {
const checkResult = checkArea({ width, height, left, top })
// Get the image from S3 // Get the image from S3
const { Body } = await s3.send( const { Body } = await s3.send(
new GetObjectCommand({ new GetObjectCommand({
@ -32,45 +33,28 @@ const cropImage = async (Key, width, height, left, top) => {
}), }),
) )
// Convert stream to buffer
const chunks = [] const chunks = []
for await (const chunk of Body) { for await (const chunk of Body) {
chunks.push(chunk) chunks.push(chunk)
} }
const buffer = Buffer.concat(chunks) const imageBuffer = Buffer.concat(chunks)
const image = await Jimp.read(buffer) let processedImage
if (!checkResult) {
image.autocrop({ tolerance: 0.0002, leaveBorder: 10 }) processedImage = await sharp(imageBuffer).toBuffer()
return await image.getBuffer('image/png') } else {
processedImage = await sharp(imageBuffer)
// Convert stream to buffer .extract({
// const chunks = [] width: parseInt(width),
// for await (const chunk of Body) { height: parseInt(height),
// chunks.push(chunk) left: parseInt(left),
// } top: parseInt(top),
// const imageBuffer = Buffer.concat(chunks) })
.png()
// const image = await Jimp.read(Body) .toBuffer()
}
// if (!checkResult) { return processedImage
// processedImage = await image.toBuffer()
// }
//let processedImage
// if (!checkResult) {
// processedImage = await sharp(imageBuffer).toBuffer()
// } else {
// processedImage = await sharp(imageBuffer)
// .extract({
// width: parseInt(width),
// height: parseInt(height),
// left: parseInt(left),
// top: parseInt(top),
// })
// .png()
// .toBuffer()
// }
// return processedImage
} catch (error) { } catch (error) {
console.error('Error processing image:', error) console.error('Error processing image:', error)
throw error throw error

View File

@ -25,8 +25,6 @@ import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupSta
import { useImgLoader } from '@/hooks/floorPlan/useImgLoader' import { useImgLoader } from '@/hooks/floorPlan/useImgLoader'
import { usePlan } from '@/hooks/usePlan' import { usePlan } from '@/hooks/usePlan'
import { QcastContext } from '@/app/QcastProvider' import { QcastContext } from '@/app/QcastProvider'
import { fabric } from 'fabric'
import { fontSelector } from '@/store/fontAtom'
const ALLOCATION_TYPE = { const ALLOCATION_TYPE = {
AUTO: 'auto', AUTO: 'auto',
@ -46,9 +44,6 @@ export default function CircuitTrestleSetting({ id }) {
const { managementState, setManagementState } = useContext(GlobalDataContext) const { managementState, setManagementState } = useContext(GlobalDataContext)
const selectedModules = useRecoilValue(selectedModuleState) const selectedModules = useRecoilValue(selectedModuleState)
const { getPcsAutoRecommendList, getPcsVoltageChk, getPcsVoltageStepUpList, getPcsManualConfChk } = useMasterController() const { getPcsAutoRecommendList, getPcsVoltageChk, getPcsVoltageStepUpList, getPcsManualConfChk } = useMasterController()
const flowText = useRecoilValue(fontSelector('flowText'))
const lengthText = useRecoilValue(fontSelector('lengthText'))
const circuitNumberText = useRecoilValue(fontSelector('circuitNumberText'))
// () // ()
const [selectedStepUpValues, setSelectedStepUpValues] = useState({}) const [selectedStepUpValues, setSelectedStepUpValues] = useState({})
@ -107,26 +102,10 @@ export default function CircuitTrestleSetting({ id }) {
} }
}, []) }, [])
// const handleZoomClear = () => {
const beforeCapture = () => {
// setCanvasZoom(100)
const x = canvas.width / 2
const y = canvas.height / 2
canvas.zoomToPoint(new fabric.Point(x, y), 0.5)
changeFontSize('lengthText', '28')
changeFontSize('circuitNumber', '28')
changeFontSize('flowText', '28')
canvas.renderAll()
}
//
const afterCapture = () => {
setCanvasZoom(100) setCanvasZoom(100)
canvas.set({ zoom: 1 }) canvas.set({ zoom: 1 })
canvas.viewportTransform = [1, 0, 0, 1, 0, 0] canvas.viewportTransform = [1, 0, 0, 1, 0, 0]
changeFontSize('lengthText', lengthText.fontSize.value)
changeFontSize('circuitNumber', circuitNumberText.fontSize.value)
changeFontSize('flowText', flowText.fontSize.value)
canvas.renderAll() canvas.renderAll()
} }
@ -371,7 +350,7 @@ export default function CircuitTrestleSetting({ id }) {
// () // ()
const onApply = async () => { const onApply = async () => {
beforeCapture() handleZoomClear()
setAllModuleSurfaceIsComplete(false) setAllModuleSurfaceIsComplete(false)
setIsGlobalLoading(true) setIsGlobalLoading(true)
@ -382,9 +361,12 @@ export default function CircuitTrestleSetting({ id }) {
obj.pcses = getStepUpListData() obj.pcses = getStepUpListData()
}) })
setViewCircuitNumberTexts(false)
handleCanvasToPng(1) handleCanvasToPng(1)
// result=null // result=null
setViewCircuitNumberTexts(true)
// //
// //
@ -400,7 +382,6 @@ export default function CircuitTrestleSetting({ id }) {
if (result) { if (result) {
handleCanvasToPng(2) handleCanvasToPng(2)
afterCapture()
// //
await saveEstimate(result) await saveEstimate(result)
} else { } else {
@ -410,16 +391,6 @@ export default function CircuitTrestleSetting({ id }) {
// removeNotAllocationModules() // removeNotAllocationModules()
} }
const changeFontSize = (name, size) => {
const textObjs = canvas?.getObjects().filter((obj) => obj.name === name)
textObjs.forEach((obj) => {
obj.set({
fontSize: size,
})
})
canvas.renderAll()
}
// //
const onClickPrev = () => { const onClickPrev = () => {
// setAllocationType(ALLOCATION_TYPE.AUTO) // setAllocationType(ALLOCATION_TYPE.AUTO)

View File

@ -56,20 +56,19 @@ export default function StuffSubHeader({ type }) {
*/ */
const moveFloorPlan = () => { const moveFloorPlan = () => {
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
const param = { const param = {
pid: managementState?.planList?.length > 0 ? managementState?.planList[0].planNo : '1', pid: managementState?.planList?.length === 0 ? '1' : managementState?.planList[0].planNo,
objectNo: objectNo, objectNo: objectNo,
} }
if (managementState?.planList?.length > 0) { if (managementState?.planList?.length === 0) {
setSelectedMenu('surface')
} else {
if (managementState?.planList[0].estimateDate) { if (managementState?.planList[0].estimateDate) {
setSelectedMenu('module') setSelectedMenu('module')
} else { } else {
setSelectedMenu('surface') setSelectedMenu('surface')
} }
} else {
setSelectedMenu('surface')
} }
const url = `/floor-plan?${queryStringFormatter(param)}` const url = `/floor-plan?${queryStringFormatter(param)}`

View File

@ -314,8 +314,7 @@ export function useRoofAllocationSetting(id) {
setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial, true) setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial, true)
drawDirectionArrow(currentObject) drawDirectionArrow(currentObject)
modifyModuleSelectionData() modifyModuleSelectionData()
// closeAll() closeAll()
closePopup(id)
basicSettingSave() basicSettingSave()
setModuleSelectionData({ ...moduleSelectionData, roofConstructions: newRoofList }) setModuleSelectionData({ ...moduleSelectionData, roofConstructions: newRoofList })
} }