removed consoles in comparing layouts
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { CompareProduct, comparsionMaterialData, useCompareProductDataStore, useInputValues, useMachineDowntime, useMachineUptime, useProductionCapacityData, useROISummaryData, useThroughPutData } from '../../../../store/builder/store';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
import { saveSimulationData } from '../../../../components/layout/scenes/functions/simulationStorage';
|
||||
import { set } from 'immer/dist/internal';
|
||||
import { usePlayButtonStore } from '../../../../store/ui/usePlayButtonStore';
|
||||
import React, { useEffect } from "react";
|
||||
import {
|
||||
CompareProduct,
|
||||
comparsionMaterialData,
|
||||
useCompareProductDataStore,
|
||||
useInputValues,
|
||||
useMachineDowntime,
|
||||
useMachineUptime,
|
||||
useProductionCapacityData,
|
||||
useROISummaryData,
|
||||
useThroughPutData,
|
||||
} from "../../../../store/builder/store";
|
||||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
|
||||
import { usePlayButtonStore } from "../../../../store/ui/usePlayButtonStore";
|
||||
|
||||
export default function ROIData() {
|
||||
const { inputValues } = useInputValues();
|
||||
@@ -15,8 +24,8 @@ export default function ROIData() {
|
||||
const { compareProductsData, setCompareProductsData } = useCompareProductDataStore();
|
||||
const { machineActiveTime } = useMachineUptime();
|
||||
const { machineIdleTime } = useMachineDowntime();
|
||||
const { throughputData } = useThroughPutData()
|
||||
const { materialData, setMaterialData } = comparsionMaterialData()
|
||||
const { throughputData } = useThroughPutData();
|
||||
const { setMaterialData } = comparsionMaterialData();
|
||||
|
||||
useEffect(() => {
|
||||
if (isPlaying) return;
|
||||
@@ -29,6 +38,7 @@ export default function ROIData() {
|
||||
netProfit: 0,
|
||||
netLoss: 0,
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isPlaying]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -47,7 +57,20 @@ export default function ROIData() {
|
||||
const shiftsPerDay = parseFloat(inputValues["Shifts / day"]);
|
||||
const workingDaysPerYear = parseFloat(inputValues["Working days / year"]);
|
||||
|
||||
if (!isNaN(electricityCost) && !isNaN(fixedCost) && !isNaN(laborCost) && !isNaN(maintenanceCost) && !isNaN(materialCost) && !isNaN(productionPeriod) && !isNaN(salvageValue) && !isNaN(sellingPrice) && !isNaN(shiftLength) && !isNaN(shiftsPerDay) && !isNaN(workingDaysPerYear) && productionCapacityData > 0) {
|
||||
if (
|
||||
!isNaN(electricityCost) &&
|
||||
!isNaN(fixedCost) &&
|
||||
!isNaN(laborCost) &&
|
||||
!isNaN(maintenanceCost) &&
|
||||
!isNaN(materialCost) &&
|
||||
!isNaN(productionPeriod) &&
|
||||
!isNaN(salvageValue) &&
|
||||
!isNaN(sellingPrice) &&
|
||||
!isNaN(shiftLength) &&
|
||||
!isNaN(shiftsPerDay) &&
|
||||
!isNaN(workingDaysPerYear) &&
|
||||
productionCapacityData > 0
|
||||
) {
|
||||
// const totalHoursPerYear = shiftLength * shiftsPerDay * workingDaysPerYear;
|
||||
// const annualProductionUnits = productionCapacityData * totalHoursPerYear;
|
||||
// const annualRevenue = annualProductionUnits * sellingPrice;
|
||||
@@ -130,7 +153,8 @@ export default function ROIData() {
|
||||
|
||||
const ROI = (Net_profit / initialInvestment) * 100;
|
||||
|
||||
const Annual_net_profit = Annual_units * (sellingPrice - materialCost - laborCost) - (maintenanceCost + electricityCost + fixedCost) * workingDaysPerYear + salvageValue * workingDaysPerYear;
|
||||
const Annual_net_profit =
|
||||
Annual_units * (sellingPrice - materialCost - laborCost) - (maintenanceCost + electricityCost + fixedCost) * workingDaysPerYear + salvageValue * workingDaysPerYear;
|
||||
const Payback_period_years = initialInvestment / Annual_net_profit;
|
||||
const data = {
|
||||
productName: selectedProduct.productName,
|
||||
@@ -139,14 +163,13 @@ export default function ROIData() {
|
||||
totalCost: Total_cost,
|
||||
revenueGenerated: Total_revenue,
|
||||
netProfit: Net_profit > 0 ? Net_profit : 0,
|
||||
netLoss: Net_profit < 0 ? -Net_profit : 0
|
||||
}
|
||||
console.log('selectedProduct.productUuid: ', selectedProduct.productUuid);
|
||||
|
||||
// saveSimulationData({ key: selectedProduct.productUuid, data: data });
|
||||
netLoss: Net_profit < 0 ? -Net_profit : 0,
|
||||
};
|
||||
console.log("selectedProduct.productUuid: ", selectedProduct.productUuid);
|
||||
|
||||
const datas = {
|
||||
roi: data
|
||||
}
|
||||
roi: data,
|
||||
};
|
||||
setMaterialData(datas);
|
||||
|
||||
setRoiSummaryData({
|
||||
@@ -193,6 +216,7 @@ export default function ROIData() {
|
||||
setCompareProductsData([...prev, newData]);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [inputValues, productionCapacityData, throughputData, isPlaying]);
|
||||
|
||||
useEffect(() => {}, [compareProductsData]);
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import { useEffect } from 'react'
|
||||
import { comparsionMaterialData, useInputValues, useProductionCapacityData, useThroughPutData } from '../../../../store/builder/store'
|
||||
import { useEffect } from "react";
|
||||
import { comparsionMaterialData, useInputValues, useProductionCapacityData, useThroughPutData } from "../../../../store/builder/store";
|
||||
|
||||
import { saveSimulationData } from '../../../../components/layout/scenes/functions/simulationStorage';
|
||||
import { usePlayButtonStore } from '../../../../store/ui/usePlayButtonStore';
|
||||
import { usePlayButtonStore } from "../../../../store/ui/usePlayButtonStore";
|
||||
|
||||
export default function ProductionCapacityData() {
|
||||
const { throughputData } = useThroughPutData();
|
||||
const { setProductionCapacityData } = useProductionCapacityData();
|
||||
const { inputValues } = useInputValues();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { materialData, setMaterialData } = comparsionMaterialData()
|
||||
|
||||
const { materialData, setMaterialData } = comparsionMaterialData();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPlaying) {
|
||||
setProductionCapacityData(0);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isPlaying]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -26,7 +25,6 @@ export default function ProductionCapacityData() {
|
||||
const Monthly_working_days = workingDaysPerYear / 12;
|
||||
const Production_capacity_per_month = throughputData * Monthly_working_days;
|
||||
const data = Number(Production_capacity_per_month.toFixed(2));
|
||||
// saveSimulationData({ key: 'productionCapacity', data: data });
|
||||
setMaterialData({ ...materialData, productionCapacity: data });
|
||||
setProductionCapacityData(Number(Production_capacity_per_month.toFixed(2)));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { useEffect } from 'react';
|
||||
import { determineExecutionMachineSequences } from '../../simulator/functions/determineExecutionMachineSequences';
|
||||
import { comparsionMaterialData, useInputValues, useMachineCount, useMachineDowntime, useMachineUptime, useMaterialCycle, useProcessBar, useThroughPutData } from '../../../../store/builder/store';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
import { saveSimulationData } from '../../../../components/layout/scenes/functions/simulationStorage';
|
||||
import { usePlayButtonStore } from '../../../../store/ui/usePlayButtonStore';
|
||||
import { useEffect } from "react";
|
||||
import { determineExecutionMachineSequences } from "../../simulator/functions/determineExecutionMachineSequences";
|
||||
import { comparsionMaterialData, useInputValues, useMachineCount, useMachineDowntime, useMachineUptime, useMaterialCycle, useProcessBar, useThroughPutData } from "../../../../store/builder/store";
|
||||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
import { usePlayButtonStore } from "../../../../store/ui/usePlayButtonStore";
|
||||
|
||||
export default function ThroughPutData() {
|
||||
const { materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore, productStore } = useSceneContext();
|
||||
@@ -22,7 +21,7 @@ export default function ThroughPutData() {
|
||||
const { setThroughputData } = useThroughPutData();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { inputValues } = useInputValues();
|
||||
const { materialData, setMaterialData } = comparsionMaterialData()
|
||||
const { materialData, setMaterialData } = comparsionMaterialData();
|
||||
|
||||
// Setting machine count
|
||||
let totalItems = 0;
|
||||
@@ -209,6 +208,7 @@ export default function ThroughPutData() {
|
||||
return () => {
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [armBots, materials, materialHistory, machines, vehicles, selectedProduct?.productUuid]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -220,13 +220,11 @@ export default function ThroughPutData() {
|
||||
const Units_per_shift = (shiftLength * 60) / (materialCycleTime / 60);
|
||||
|
||||
const Throughput_per_day = Units_per_shift * shiftsPerDay * (yieldRate / 100);
|
||||
const data = Number(Throughput_per_day.toFixed(2))
|
||||
console.log('data: ', data);
|
||||
// saveSimulationData({ key: selectedProduct.productUuid, data: data });
|
||||
|
||||
const data = Number(Throughput_per_day.toFixed(2));
|
||||
setMaterialData({ ...materialData, throughput: data });
|
||||
setThroughputData(Number(Throughput_per_day.toFixed(2))); // Keep as number
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [materialCycleTime, machineCount, isPlaying, inputValues, materialData]);
|
||||
|
||||
return <></>;
|
||||
|
||||
Reference in New Issue
Block a user