feat: update simulation data structure and improve performance metrics display
This commit is contained in:
parent
b350bc6d9e
commit
064de39eac
|
@ -31,27 +31,29 @@ function ComparisonScene() {
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// setCompareProductsData([
|
// setCompareProductsData([
|
||||||
// {
|
// {
|
||||||
// productUuid: "15193386-ec58-4ec6-8a92-e665a39eebf1",
|
// "productUuid": "15193386-ec58-4ec6-8a92-e665a39eebf1",
|
||||||
// productName: "Product 1",
|
// "productName": "Product 1",
|
||||||
// simulationData: {
|
// "simulationData": {
|
||||||
// roiPercentage: 65.54,
|
// "roiPercentage": 273.9428571428571,
|
||||||
// netProfit: 499037750,
|
// "paybackPeriod": 1.8251981643721318,
|
||||||
// machineIdleTime: 1024,
|
// "netProfit": 9588000,
|
||||||
// machineActiveTime: 235,
|
// "productionCapacity": 4508.5,
|
||||||
// productionCapacity: 1000,
|
// "machineIdleTime": 1450,
|
||||||
// throughputData: 62.42
|
// "machineActiveTime": 430,
|
||||||
|
// "throughputData": 180.34
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// productUuid: "f614bf50-f61d-41c5-acc0-3783fb4da6b8",
|
// "productUuid": "f614bf50-f61d-41c5-acc0-3783fb4da6b8",
|
||||||
// productName: "Product 2",
|
// "productName": "Product 2",
|
||||||
// simulationData: {
|
// "simulationData": {
|
||||||
// roiPercentage: 169.99,
|
// "roiPercentage": 281.7214285714286,
|
||||||
// netProfit: 1282397750,
|
// "paybackPeriod": 1.7748028701097842,
|
||||||
// machineIdleTime: 1897,
|
// "netProfit": 9860250,
|
||||||
// machineActiveTime: 653,
|
// "productionCapacity": 4599.25,
|
||||||
// productionCapacity: 2000,
|
// "machineIdleTime": 1885,
|
||||||
// throughputData: 157.03
|
// "machineActiveTime": 646,
|
||||||
|
// "throughputData": 183.97
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// ])
|
// ])
|
||||||
|
|
|
@ -99,9 +99,9 @@ const ROISummary = ({
|
||||||
|
|
||||||
function getPaybackDateFromYears(yearsToAdd: number) {
|
function getPaybackDateFromYears(yearsToAdd: number) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
console.log('yearsToAdd: ', yearsToAdd);
|
|
||||||
const totalMonths = Math.round(yearsToAdd * 12);
|
const totalMonths = Math.round(yearsToAdd * 12);
|
||||||
console.log('totalMonths: ', totalMonths);
|
|
||||||
const paybackDate = new Date(now.getFullYear(), now.getMonth() + totalMonths, now.getDate());
|
const paybackDate = new Date(now.getFullYear(), now.getMonth() + totalMonths, now.getDate());
|
||||||
const month = paybackDate.toLocaleString("en-GB", { month: "long" });
|
const month = paybackDate.toLocaleString("en-GB", { month: "long" });
|
||||||
const year = paybackDate.getFullYear();
|
const year = paybackDate.getFullYear();
|
||||||
|
|
|
@ -55,7 +55,7 @@ const ProductionCapacity = ({
|
||||||
<>
|
<>
|
||||||
<div className="process-container">
|
<div className="process-container">
|
||||||
<div className="throughput-value">
|
<div className="throughput-value">
|
||||||
<span className="value">{(Units_per_hour).toFixed(2)}</span> Units/hour
|
<span className="value">{(Units_per_hour).toFixed(2) === "Infinity"? 0 : (Units_per_hour).toFixed(2) }</span> Units/hour
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Dynamic Progress Bar */}
|
{/* Dynamic Progress Bar */}
|
||||||
|
|
|
@ -32,7 +32,7 @@ const ComparisonResult = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (comparedProducts.length === 2) {
|
if (comparedProducts.length === 2) {
|
||||||
console.log(comparedProducts);
|
|
||||||
}
|
}
|
||||||
}, [comparedProducts]);
|
}, [comparedProducts]);
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ const ComparisonResult = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PerformanceResult />
|
{ comparedProducts.length === 2 &&<PerformanceResult comparedProducts={comparedProducts}/>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,7 +5,8 @@ import {
|
||||||
TickIcon,
|
TickIcon,
|
||||||
} from "../../../icons/ExportCommonIcons";
|
} from "../../../icons/ExportCommonIcons";
|
||||||
|
|
||||||
const PerformanceResult = () => {
|
const PerformanceResult = ({ comparedProducts }: any) => {
|
||||||
|
const ProfitProduct = comparedProducts[0].simulationData.netProfit > comparedProducts[1].simulationData.netProfit ? comparedProducts[0] : comparedProducts[1];
|
||||||
return (
|
return (
|
||||||
<div className="performanceResult-wrapper comparisionCard">
|
<div className="performanceResult-wrapper comparisionCard">
|
||||||
<div className="header">
|
<div className="header">
|
||||||
|
@ -26,30 +27,30 @@ const PerformanceResult = () => {
|
||||||
</div>
|
</div>
|
||||||
<div className="metric-value">98%</div>
|
<div className="metric-value">98%</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="label">Environmental impact</div>
|
<div className="label">Net Profit</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="metrics-right">
|
<div className="metrics-right">
|
||||||
<div className="metric-wrapper">
|
<div className="metric-wrapper">
|
||||||
<div className="metric-label">Waste generation</div>
|
<div className="metric-label">ROI Percentage</div>
|
||||||
<div className="metric">
|
<div className="metric">
|
||||||
<div className="metric-icon">I</div>
|
<div className="metric-icon"></div>
|
||||||
<div className="metric-value">0.5%</div>
|
<div className="metric-value">{ProfitProduct.simulationData.roiPercentage.toFixed(2)}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="metric-wrapper">
|
<div className="metric-wrapper">
|
||||||
<div className="metric-label">Risk
management</div>
|
<div className="metric-label">Payback Period</div>
|
||||||
<div className="metric">
|
<div className="metric">
|
||||||
<div className="metric-icon">I</div>
|
<div className="metric-icon"></div>
|
||||||
<div className="metric-value">0.1%</div>
|
<div className="metric-value">{ProfitProduct.simulationData.netProfit}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="metric-wrapper">
|
<div className="metric-wrapper">
|
||||||
<div className="metric">
|
<div className="metric">
|
||||||
<div className="metric-icon">I</div>
|
<div className="metric-icon"></div>
|
||||||
<div className="metric-value">0.5%</div>
|
<div className="metric-value">{parseFloat(ProfitProduct.simulationData.paybackPeriod.toFixed(2))}years</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default function ROIData() {
|
||||||
if (!isNaN(electricityCost) && !isNaN(fixedCost) && !isNaN(laborCost) && !isNaN(maintenanceCost) &&
|
if (!isNaN(electricityCost) && !isNaN(fixedCost) && !isNaN(laborCost) && !isNaN(maintenanceCost) &&
|
||||||
!isNaN(materialCost) && !isNaN(productionPeriod) && !isNaN(salvageValue) && !isNaN(sellingPrice) &&
|
!isNaN(materialCost) && !isNaN(productionPeriod) && !isNaN(salvageValue) && !isNaN(sellingPrice) &&
|
||||||
!isNaN(shiftLength) && !isNaN(shiftsPerDay) && !isNaN(workingDaysPerYear) && productionCapacityData > 0) {
|
!isNaN(shiftLength) && !isNaN(shiftsPerDay) && !isNaN(workingDaysPerYear) && productionCapacityData > 0) {
|
||||||
console.log('productionCapacityData: ', productionCapacityData);
|
|
||||||
|
|
||||||
// const totalHoursPerYear = shiftLength * shiftsPerDay * workingDaysPerYear;
|
// const totalHoursPerYear = shiftLength * shiftsPerDay * workingDaysPerYear;
|
||||||
// const annualProductionUnits = productionCapacityData * totalHoursPerYear;
|
// const annualProductionUnits = productionCapacityData * totalHoursPerYear;
|
||||||
|
@ -158,6 +158,7 @@ export default function ROIData() {
|
||||||
// shiftLength: shiftLength,
|
// shiftLength: shiftLength,
|
||||||
// shiftsPerDay: shiftsPerDay,
|
// shiftsPerDay: shiftsPerDay,
|
||||||
roiPercentage: ROI,
|
roiPercentage: ROI,
|
||||||
|
paybackPeriod: Payback_period_years,
|
||||||
// paybackPeriod: paybackPeriod,
|
// paybackPeriod: paybackPeriod,
|
||||||
// totalCost: totalAnnualCost,
|
// totalCost: totalAnnualCost,
|
||||||
// revenueGenerated: annualRevenue,
|
// revenueGenerated: annualRevenue,
|
||||||
|
@ -186,7 +187,7 @@ export default function ROIData() {
|
||||||
}, [inputValues, productionCapacityData, throughputData, isPlaying]);
|
}, [inputValues, productionCapacityData, throughputData, isPlaying]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('compareProductsData: ', compareProductsData);
|
|
||||||
}, [compareProductsData])
|
}, [compareProductsData])
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default function ProductionCapacityData() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPlaying) {
|
if (!isPlaying) {
|
||||||
console.log('isPlaying: ', isPlaying);
|
|
||||||
setProductionCapacityData(0);
|
setProductionCapacityData(0);
|
||||||
}
|
}
|
||||||
}, [isPlaying]);
|
}, [isPlaying]);
|
||||||
|
@ -25,8 +25,8 @@ export default function ProductionCapacityData() {
|
||||||
if (!isNaN(workingDaysPerYear) && throughputData > 0) {
|
if (!isNaN(workingDaysPerYear) && throughputData > 0) {
|
||||||
const Monthly_working_days = workingDaysPerYear / 12;
|
const Monthly_working_days = workingDaysPerYear / 12;
|
||||||
const Production_capacity_per_month = throughputData * Monthly_working_days;
|
const Production_capacity_per_month = throughputData * Monthly_working_days;
|
||||||
console.log('Production_capacity_per_month: ', Production_capacity_per_month);
|
|
||||||
console.log('throughputData: ', throughputData);
|
|
||||||
|
|
||||||
setProductionCapacityData(Number(Production_capacity_per_month.toFixed(2)));
|
setProductionCapacityData(Number(Production_capacity_per_month.toFixed(2)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ export default function ThroughPutData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const allInactive = !anyArmActive && !anyVehicleActive && !anyMachineActive;
|
const allInactive = !anyArmActive && !anyVehicleActive && !anyMachineActive;
|
||||||
if (allInactive && materials.length === 0 && materialHistory.length > 0) {
|
if (materials.length >= 0 && materialHistory.length > 0) {
|
||||||
|
|
||||||
let totalCycleTimeSum = 0;
|
let totalCycleTimeSum = 0;
|
||||||
let cycleCount = 0;
|
let cycleCount = 0;
|
||||||
|
|
|
@ -43,7 +43,7 @@ const UserAuth: React.FC = () => {
|
||||||
const organization = email.split("@")[1].split(".")[0];
|
const organization = email.split("@")[1].split(".")[0];
|
||||||
try {
|
try {
|
||||||
const res = await signInApi(email, password, organization, fingerprint);
|
const res = await signInApi(email, password, organization, fingerprint);
|
||||||
console.log('res: ', res);
|
// console.log('res: ', res);
|
||||||
if (res.message.message === "login successfull") {
|
if (res.message.message === "login successfull") {
|
||||||
setError("");
|
setError("");
|
||||||
setOrganization(organization);
|
setOrganization(organization);
|
||||||
|
@ -56,10 +56,10 @@ const UserAuth: React.FC = () => {
|
||||||
localStorage.setItem("refreshToken", res.message.refreshToken);
|
localStorage.setItem("refreshToken", res.message.refreshToken);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('res.message.userId: ', res.message.userId);
|
// console.log('res.message.userId: ', res.message.userId);
|
||||||
console.log('organization: ', organization);
|
// console.log('organization: ', organization);
|
||||||
const projects = await recentlyViewed(organization, res.message.userId);
|
const projects = await recentlyViewed(organization, res.message.userId);
|
||||||
console.log('projects: ', projects);
|
// console.log('projects: ', projects);
|
||||||
|
|
||||||
if (res.message.isShare) {
|
if (res.message.isShare) {
|
||||||
if (Object.values(projects.RecentlyViewed).length > 0) {
|
if (Object.values(projects.RecentlyViewed).length > 0) {
|
||||||
|
|
|
@ -727,6 +727,7 @@ export interface CompareProduct {
|
||||||
// revenueGenerated: number;
|
// revenueGenerated: number;
|
||||||
netProfit: number;
|
netProfit: number;
|
||||||
productionCapacity: number;
|
productionCapacity: number;
|
||||||
|
paybackPeriod: number;
|
||||||
// netLoss: number;
|
// netLoss: number;
|
||||||
machineIdleTime: number;
|
machineIdleTime: number;
|
||||||
machineActiveTime: number;
|
machineActiveTime: number;
|
||||||
|
|
Loading…
Reference in New Issue