Merge remote-tracking branch 'origin/feature/layout-comparison-version' into dev-heatmap
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { useEffect } from "react";
|
||||
import { CompareProduct, useCompareProductDataStore, useInputValues, useMachineDowntime, useMachineUptime, useProductionCapacityData, useROISummaryData, useThroughPutData } from "../../../../store/builder/store";
|
||||
import { usePlayButtonStore } from "../../../../store/ui/usePlayButtonStore";
|
||||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
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';
|
||||
|
||||
export default function ROIData() {
|
||||
const { inputValues } = useInputValues();
|
||||
@@ -13,7 +15,8 @@ export default function ROIData() {
|
||||
const { compareProductsData, setCompareProductsData } = useCompareProductDataStore();
|
||||
const { machineActiveTime } = useMachineUptime();
|
||||
const { machineIdleTime } = useMachineDowntime();
|
||||
const { throughputData } = useThroughPutData();
|
||||
const { throughputData } = useThroughPutData()
|
||||
const { materialData, setMaterialData } = comparsionMaterialData()
|
||||
|
||||
useEffect(() => {
|
||||
if (isPlaying) return;
|
||||
@@ -129,6 +132,22 @@ export default function ROIData() {
|
||||
|
||||
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,
|
||||
roiPercentage: ROI,
|
||||
paybackPeriod: Payback_period_years,
|
||||
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 });
|
||||
const datas = {
|
||||
roi: data
|
||||
}
|
||||
setMaterialData(datas);
|
||||
|
||||
setRoiSummaryData({
|
||||
productName: selectedProduct.productName,
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import { useEffect } from "react";
|
||||
import { useInputValues, useProductionCapacityData, useThroughPutData } from "../../../../store/builder/store";
|
||||
import { usePlayButtonStore } from "../../../../store/ui/usePlayButtonStore";
|
||||
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';
|
||||
|
||||
export default function ProductionCapacityData() {
|
||||
const { throughputData } = useThroughPutData();
|
||||
const { setProductionCapacityData } = useProductionCapacityData();
|
||||
const { inputValues } = useInputValues();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { materialData, setMaterialData } = comparsionMaterialData()
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPlaying) {
|
||||
@@ -21,10 +25,12 @@ export default function ProductionCapacityData() {
|
||||
if (!isNaN(workingDaysPerYear) && throughputData > 0) {
|
||||
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)));
|
||||
}
|
||||
}, [throughputData, inputValues, isPlaying]);
|
||||
}, [throughputData, inputValues, isPlaying, materialData]);
|
||||
|
||||
return <></>;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useEffect } from "react";
|
||||
import { determineExecutionMachineSequences } from "../../simulator/functions/determineExecutionMachineSequences";
|
||||
import { useInputValues, useMachineCount, useMachineDowntime, useMachineUptime, useMaterialCycle, useProcessBar, useThroughPutData } from "../../../../store/builder/store";
|
||||
import { usePlayButtonStore } from "../../../../store/ui/usePlayButtonStore";
|
||||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
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';
|
||||
|
||||
export default function ThroughPutData() {
|
||||
const { materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore, productStore } = useSceneContext();
|
||||
@@ -21,6 +22,7 @@ export default function ThroughPutData() {
|
||||
const { setThroughputData } = useThroughPutData();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { inputValues } = useInputValues();
|
||||
const { materialData, setMaterialData } = comparsionMaterialData()
|
||||
|
||||
// Setting machine count
|
||||
let totalItems = 0;
|
||||
@@ -218,9 +220,13 @@ 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))
|
||||
saveSimulationData({ key: selectedProduct.productUuid, data: data });
|
||||
|
||||
setMaterialData({ ...materialData, throughput: data });
|
||||
setThroughputData(Number(Throughput_per_day.toFixed(2))); // Keep as number
|
||||
}
|
||||
}, [materialCycleTime, machineCount, isPlaying, inputValues]);
|
||||
}, [materialCycleTime, machineCount, isPlaying, inputValues, materialData]);
|
||||
|
||||
return <></>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user