修改
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
import axios from "@/utils/request";
|
||||
import { deepClone } from "../../utils";
|
||||
|
||||
@@ -15,7 +16,25 @@ const state = {
|
||||
/* 能源驾驶舱 */
|
||||
energy: {},
|
||||
/* 效率驾驶舱 */
|
||||
efficiency: {},
|
||||
efficiency: {
|
||||
chipOee: {
|
||||
current: [],
|
||||
previous: [],
|
||||
},
|
||||
transformRate: {
|
||||
current: [],
|
||||
previous: [],
|
||||
},
|
||||
chipRate: {
|
||||
target: [],
|
||||
current: [],
|
||||
previous: [],
|
||||
},
|
||||
stdRate: {
|
||||
target: [],
|
||||
current: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
home: {
|
||||
/** 主页状态 */
|
||||
@@ -48,7 +67,11 @@ const mutations = {
|
||||
state.copilot.energy = payload.data;
|
||||
break;
|
||||
case "efficiency":
|
||||
state.copilot.efficiency = payload.data;
|
||||
console.log('222222', payload.chipOee)
|
||||
state.copilot.efficiency.chipOee = payload.chipOee;
|
||||
state.copilot.efficiency.transformRate = payload.transformRate;
|
||||
state.copilot.efficiency.chipRate = payload.chipRate;
|
||||
state.copilot.efficiency.stdRate = payload.stdRate;
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -64,20 +87,29 @@ const actions = {
|
||||
},
|
||||
/** 初始化驾驶舱数据 */
|
||||
async initCopilot({ commit }, { period, source }) {
|
||||
if (source == "comprehensive") return;
|
||||
|
||||
const fetcher = {
|
||||
yield: getCopilotYield,
|
||||
energy: getCopilotEnergy,
|
||||
comprehensive: getCopilotEnergy,
|
||||
efficiency: getCopilotEfficiency,
|
||||
}[source];
|
||||
const handler = {
|
||||
yield: splitCurrentAndPrevious,
|
||||
comprehensive: () => null,
|
||||
efficiency: splitCurrentAndPreviousA,
|
||||
}[source];
|
||||
// 获取产量数据
|
||||
// console.log('qqqqqq',handler)
|
||||
let { data: factoryList, type } = await fetcher(period);
|
||||
let targetList = null;
|
||||
if (source === "yield" || source === "efficiency") {
|
||||
// 获取目标数据
|
||||
let { data } = await fetcher(period, true);
|
||||
let { data } = await fetcher(period, true)
|
||||
console.log('11111',data)
|
||||
targetList = data;
|
||||
}
|
||||
const payload = splitCurrentAndPrevious(factoryList, targetList);
|
||||
const payload = handler(factoryList, targetList);
|
||||
commit("SET_COPILOT_INFO", { type, payload });
|
||||
},
|
||||
};
|
||||
@@ -89,7 +121,103 @@ export default {
|
||||
actions,
|
||||
};
|
||||
|
||||
function splitCurrentAndPreviousA(factoryListResponse, targetListResponse) {
|
||||
console.log('工厂',factoryListResponse);
|
||||
// console.log('工厂',factoryListResponse);
|
||||
|
||||
// 初始数据
|
||||
const { chipOee, transformRate, chipRate, stdRate } = initA();
|
||||
factoryListResponse = [
|
||||
{
|
||||
factory: 0,
|
||||
oee: 0.8,
|
||||
previousYearOee: 0.7,
|
||||
componentConversionEfficiency: 0.8,
|
||||
previousYearComponentConversionEfficiency: 0.7,
|
||||
glassType: 0,
|
||||
yieldRate: 0.8,
|
||||
previousYearYieldRate: 0.7,
|
||||
chipYieldRate: 0.38,
|
||||
componentYieldRate: 0.73,
|
||||
},
|
||||
{
|
||||
factory: 1,
|
||||
oee: 0.8,
|
||||
previousYearOee: 0.7,
|
||||
componentConversionEfficiency: 0.8,
|
||||
previousYearComponentConversionEfficiency: 0.7,
|
||||
glassType: 1,
|
||||
yieldRate: 0.8,
|
||||
previousYearYieldRate: 0.7,
|
||||
chipYieldRate: 0.38,
|
||||
componentYieldRate: 0.73,
|
||||
},
|
||||
{
|
||||
factory: 2,
|
||||
oee: 0.8,
|
||||
previousYearOee: 0.7,
|
||||
componentConversionEfficiency: 0.8,
|
||||
previousYearComponentConversionEfficiency: 0.7,
|
||||
glassType: 1,
|
||||
yieldRate: 0.8,
|
||||
previousYearYieldRate: 0.7,
|
||||
chipYieldRate: 0.38,
|
||||
componentYieldRate: 0.73,
|
||||
},
|
||||
{
|
||||
factory: 3,
|
||||
oee: 0.8,
|
||||
previousYearOee: 0.7,
|
||||
componentConversionEfficiency: 0.8,
|
||||
previousYearComponentConversionEfficiency: 0.7,
|
||||
glassType: 0,
|
||||
yieldRate: 0.8,
|
||||
previousYearYieldRate: 0.7,
|
||||
chipYieldRate: 0.38,
|
||||
componentYieldRate: 0.73,
|
||||
},
|
||||
];
|
||||
if (factoryListResponse) {
|
||||
for (const factory of factoryListResponse) {
|
||||
const fId = getFactoryId(factory);
|
||||
// 获取目标值
|
||||
if (targetListResponse) {
|
||||
const {
|
||||
chipYieldRate,
|
||||
componentYieldRate,
|
||||
chipOee,
|
||||
componentConversionEfficiency,
|
||||
} = getFactoryTargetValueA(targetListResponse, fId);
|
||||
stdRate.target[fId] = chipYieldRate;
|
||||
chipRate.target[fId] = componentYieldRate;
|
||||
}
|
||||
// 芯片OEE
|
||||
chipOee.current[fId] = factory.oee * 100 || random_default();
|
||||
chipOee.previous[fId] = factory.previousYearOee * 100 || random_default();
|
||||
// 转化效率
|
||||
transformRate.current[fId] =
|
||||
factory.componentConversionEfficiency * 100 || random_default();
|
||||
transformRate.previous[fId] =
|
||||
factory.previousYearComponentConversionEfficiency * 100 || random_default();
|
||||
// 芯片良率 与 标准组件良率
|
||||
if (![0, 1].includes(factory.glassType)) continue;
|
||||
const _t = [chipRate, stdRate][factory.glassType];
|
||||
_t.current[fId] = factory.yieldRate || random_default();
|
||||
_t.previous[fId] = factory.previousYearYieldRate || random_default();
|
||||
}
|
||||
|
||||
return {
|
||||
chipOee,
|
||||
transformRate,
|
||||
chipRate,
|
||||
stdRate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function splitCurrentAndPrevious(factoryListResponse, targetListResponse) {
|
||||
console.log('工厂',factoryListResponse);
|
||||
|
||||
// 初始数据
|
||||
const { chipInvest, ftoInvest, chipOutput, stdOutput, bipvOutput } = init();
|
||||
if (factoryListResponse) {
|
||||
@@ -149,9 +277,58 @@ function getFactoryTargetValue(targetList, factoryId) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 芯片良率目标值 和 标准组件良率目标值
|
||||
* @param {*} targetList 目标值列表
|
||||
* @param {*} factoryId 工厂ID
|
||||
* @returns
|
||||
*/
|
||||
function getFactoryTargetValueA(targetList, factoryId) {
|
||||
const target = targetList.find((item) => item.factory === factoryId);
|
||||
if (target) {
|
||||
return {
|
||||
chipYieldRate: target.chipYieldRate ?? random_default(),
|
||||
componentYieldRate: target.componentYieldRate ?? random_default(),
|
||||
};
|
||||
}
|
||||
return {
|
||||
chipYieldRate: random_default(),
|
||||
componentYieldRate: random_default(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns 初始化状态值
|
||||
* @returns 初始化 效率模块里 初始状态值
|
||||
*/
|
||||
function initA() {
|
||||
const t_ = {
|
||||
current: Array(7).fill(0),
|
||||
previous: Array(7).fill(0),
|
||||
};
|
||||
// 芯片OEE
|
||||
const chipOee = deepClone(t_);
|
||||
// 转化效率
|
||||
const transformRate = deepClone(t_);
|
||||
// 标准组件良率
|
||||
const stdRate = {
|
||||
...deepClone(t_),
|
||||
target: Array(7).fill(0),
|
||||
};
|
||||
// 芯片良率
|
||||
const chipRate = deepClone(stdRate);
|
||||
|
||||
return {
|
||||
chipOee,
|
||||
transformRate,
|
||||
chipRate,
|
||||
stdRate,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns 初始化 产量模块里 初始状态值
|
||||
*/
|
||||
function init() {
|
||||
const t_ = {
|
||||
@@ -181,11 +358,11 @@ function init() {
|
||||
};
|
||||
}
|
||||
|
||||
function random_default() {
|
||||
return 0;
|
||||
let a = Math.floor(Math.random() * 1000);
|
||||
while (a < 600) {
|
||||
a = Math.floor(Math.random() * 1000);
|
||||
function random_default(min = 0, max = 1) {
|
||||
// return 0;
|
||||
let a = Math.floor(Math.random() * max);
|
||||
while (a < min) {
|
||||
a = Math.floor(Math.random() * max);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user