驾驶舱对接

This commit is contained in:
‘937886381’
2024-05-17 10:31:47 +08:00
parent 6f0c8503c6
commit 208af7b565
24 changed files with 676 additions and 393 deletions

View File

@@ -14,7 +14,12 @@ const state = {
bipvOutput: null,
},
/* 能源驾驶舱 */
energy: {},
energy: {
stockDOData: [],
waterList: {},
gasList: [],
elecList:{}
},
/* 效率驾驶舱 */
efficiency: {
chipOee: {
@@ -66,10 +71,12 @@ const mutations = {
state.copilot.yield.bipvOutput = payload.bipvOutput;
break;
case "energy":
state.copilot.energy = payload.data;
state.copilot.energy.stockDOData = payload.stockDOData;
state.copilot.energy.gasList = payload.gasList;
state.copilot.energy.waterList = payload.waterList;
state.copilot.energy.elecList = payload.elecList;
break;
case "efficiency":
console.log('222222', payload)
state.copilot.efficiency.chipOee = payload.chipOee;
state.copilot.efficiency.transformRate = payload.transformRate;
state.copilot.efficiency.chipRate = payload.chipRate;
@@ -89,34 +96,38 @@ const actions = {
},
/** 初始化驾驶舱数据 */
async initCopilot({ commit }, { period, source }) {
if (source == "comprehensive") return;
// if (source == "energy") return;
const fetcher = {
yield: getCopilotYield,
comprehensive: getCopilotEnergy,
energy: getCopilotEnergy,
efficiency: getCopilotEfficiency,
}[source];
const handler = {
yield: splitCurrentAndPrevious,
comprehensive: () => null,
energy: splitCurrentAndPreviousB,
efficiency: splitCurrentAndPreviousA,
}[source]
console.log(handler)
// 获取产量数据
// console.log('qqqqqq',handler)
let { data: factoryList, type } = await fetcher(period)
console.log(factoryList,type);
let targetList = null;
if (source === "yield" || source === "efficiency") {
// 获取目标数据
let { data } = await fetcher(period, true)
// console.log('11111',data)
targetList = data
}
let factoryData = factoryList.prodOutputResultDO ? factoryList.prodOutputResultDO : factoryList.prodOutputRateDO
let targetData = targetList.prodTargetDO ? targetList.prodTargetDO : targetList.prodTargetDO
const payload = handler(factoryData, targetData)
if (source == "energy") {
let factoryData = factoryList
const payload = handler(factoryData)
commit("SET_COPILOT_INFO", { type, payload });
} else {
let factoryData = factoryList.prodOutputResultDO ? factoryList.prodOutputResultDO : factoryList.prodOutputRateDO
let targetData = targetList.prodTargetDO ? targetList.prodTargetDO : targetList.prodTargetDO
const payload = handler(factoryData, targetData)
commit("SET_COPILOT_INFO", { type, payload });
}
},
};
@@ -127,8 +138,147 @@ export default {
actions,
};
function splitCurrentAndPreviousB(factoryListResponse) {
let factoryArr = [
{
id: 0,
name: '瑞昌中建材光电材料有限公司',
stockData: [],
waterData: [],
elsData: [],
gasData: [],
},
{
id: 1,
name: '邯郸中建材光电材料有限公司',
stockData: [],
waterData: [],
elsData: [],
gasData: [],
},
{
id: 2,
name: '中建材株洲光电材料有限公司',
stockData: [],
waterData: [],
elsData: [],
gasData: [],
},
{
id: 3,
name: '佳木斯中建材光电材料有限公司',
stockData: [],
waterData: [],
elsData: [],
gasData: [],
},
{
id: 4,
name: '成都中建材光电材料有限公司',
stockData: [],
waterData: [],
elsData: [],
gasData: [],
},
{
id: 5,
name: '凯盛光伏材料有限公司',
stockData: [],
waterData: [],
elsData: [],
gasData: [],
},
{
id: 6,
name: '蚌埠兴科玻璃有限公司',
stockData: [],
waterData: [],
elsData: [],
gasData: [],
},
]
if (factoryListResponse) {
for (let i in factoryListResponse.stockDO) {
const index = factoryArr.findIndex(item => item.id == factoryListResponse.stockDO[i].factory)
if (index != -1) {
factoryListResponse.stockDO[i].stockInfo.forEach(ele => {
factoryArr[index].stockData.push(ele)
});
}
}
let stockDOData = []
factoryArr.forEach((ele, index) => [
stockDOData[index] = [],
ele.stockData.forEach((item) => {
let obj = {}
obj.name = item.glassType == 0 ? '玻璃芯片' : item.glassType == 1 ? '标准组件' : item.glassType == 2 ? 'BIPV' : '定制组件'
obj.value = item.stockNumber
stockDOData[index].push(obj)
}),
])
let gasList = []
// if (factoryListResponse.gasDO) {
factoryListResponse.gasDO.forEach((ele) => {
gasList[ele.factory] = ele.totalEnergyValue
})
// }
// console.log(factoryListResponse.gasDO);
let waterObj = Object.groupBy(factoryListResponse.waterDO, ({ groupName }) => groupName)
let waterList = {
times: [],
0: [],
1: [],
2: [],
3: [],
4: [],
5: [],
6: [],
}
for (let i in waterObj) {
waterList.times.push(i)
waterObj[i].forEach((ele, index) => {
waterList[ele.factory].push(ele.totalEnergyValue)
})
}
let elecObj = Object.groupBy(factoryListResponse.elecDO, ({ groupName }) => groupName)
let elecList = {
times: [],
0: [],
1: [],
2: [],
3: [],
4: [],
5: [],
6: [],
}
for (let i in elecObj) {
elecList.times.push(i)
elecObj[i].forEach((ele, index) => {
elecList[ele.factory].push(ele.totalEnergyValue)
})
}
return {
stockDOData,
waterList,
gasList,
elecList,
};
} else {
let stockDOData = Array[7].fill([])
let waterList = {}
return {
stockDOData,
waterList,
gasList,
elecList
};
}
}
function splitCurrentAndPreviousA(factoryListResponse, targetListResponse) {
console.log('工厂',targetListResponse);
// console.log('工厂',factoryListResponse);
// 初始数据
@@ -209,7 +359,6 @@ function splitCurrentAndPreviousA(factoryListResponse, targetListResponse) {
// 芯片良率 与 标准组件良率
if (![0, 1].includes(factory.glassType)) continue;
const _t = [chipRate, stdRate][factory.glassType]
console.log('_t',_t);
_t.current[fId] = factory.yieldRate ;
_t.previous[fId] = factory.previousYearYieldRate ;
}
@@ -224,7 +373,7 @@ function splitCurrentAndPreviousA(factoryListResponse, targetListResponse) {
}
function splitCurrentAndPrevious(factoryListResponse, targetListResponse) {
console.log('工厂',factoryListResponse);
// 初始数据
const { chipInvest, ftoInvest, chipOutput, stdOutput, bipvOutput } = init();
@@ -407,7 +556,7 @@ function getUrl(copilot_module) {
// 对比数据的 URL
comparison: "",
// 目标数据的 URL
target: "",
// target: "",
};
switch (copilot_module) {
case "yield":
@@ -415,6 +564,7 @@ function getUrl(copilot_module) {
// url.target = "/ip/prod-target/query-by-date";
break;
case "energy":
url.comparison = "ip/prod-output/cockpitComprehensiveDataMonitor";
break;
case "efficiency":
url.comparison = "ip/prod-output/cockpitDataRate";