projects/mescc/develop #24

Merged
juzi merged 94 commits from projects/mescc/develop into projects/mescc/main 2024-05-31 14:21:24 +08:00
2 changed files with 72 additions and 21 deletions
Showing only changes of commit 253f182370 - Show all commits

View File

@ -65,13 +65,13 @@ const actions = {
async initCopilot({ commit }, { period, source }) { async initCopilot({ commit }, { period, source }) {
const fetcher = { const fetcher = {
yield: getCopilotYield, yield: getCopilotYield,
energy: null, energy: getCopilotEnergy,
efficiency: null, efficiency: getCopilotEfficiency,
}[source]; }[source];
// 获取产量数据 // 获取产量数据
let { data: factoryList, type } = await fetcher(period); let { data: factoryList, type } = await fetcher(period);
let targetList = null; let targetList = null;
if (source === "yield") { if (source === "yield" || source === "efficiency") {
// 获取目标数据 // 获取目标数据
let { data } = await fetcher(period, true); let { data } = await fetcher(period, true);
targetList = data; targetList = data;
@ -210,13 +210,33 @@ async function getHomeTarget() {
return null; return null;
} }
async function fetcher(type = "yield", params) { function getUrl(copilot_module) {
let url = {
// 对比数据的 URL
comparison: "",
// 目标数据的 URL
target: "",
};
switch (copilot_module) {
case "yield":
url.comparison = "/ip/prod-output/query-by-date";
url.target = "/ip/prod-target/query-by-date";
break;
case "energy":
break;
case "efficiency":
url.comparison = "/ip/prod-output/query-Rate-List";
url.target = "/ip/prod-target/query-rate-target";
break;
}
return url;
}
async function doFetch(copilot_module = "yield", fetch_target, params) {
const url = getUrl(copilot_module);
const { code, data } = await axios.post( const { code, data } = await axios.post(
type == "yield" fetch_target ? url.target : url.comparison,
? // 产量 数据
"/ip/prod-output/query-by-date"
: // 目标数据
"/ip/prod-target/query-by-date",
{ {
...params, ...params,
} }
@ -224,17 +244,30 @@ async function fetcher(type = "yield", params) {
if (code == 0) { if (code == 0) {
return data; return data;
} }
console.warn("getCopilotYield failed, code: ", code); console.warn("[doFetch] failed, code: ", code);
return null; return null;
} }
function getCopilotYield(period, target = false) {
return getCopilotData("yield", period, target);
}
function getCopilotEnergy(period, target = false) {
return getCopilotData("energy", period, target);
}
function getCopilotEfficiency(period, target = false) {
return getCopilotData("efficiency", period, target);
}
/** /**
* *
* @param {*} period 周期 日周月年 * @param {*} period 周期 日周月年
* @param {*} target 是否获取目标数据默认 * @param {*} target 是否获取目标数据默认
* @returns * @returns
*/ */
async function getCopilotYield(period, target = false) { async function getCopilotData(copilot_module, period, target = false) {
if (!copilot_module) copilot_module = "yield";
// 请求参数,直接一次性获取所有工厂 // 请求参数,直接一次性获取所有工厂
let queryParams = { let queryParams = {
factorys: [], factorys: [],
@ -260,7 +293,7 @@ async function getCopilotYield(period, target = false) {
} }
return { return {
data: await fetcher(target ? "target" : "yield", queryParams), data: await doFetch(copilot_module, target ? true : false, queryParams),
type: "yield", type: copilot_module,
}; };
} }

View File

@ -7,23 +7,41 @@
<template> <template>
<div class="efficiency-copilot"> <div class="efficiency-copilot">
<db-container title="芯片良率" icon="chip2"></db-container> <Container title="芯片良率" icon="chip2"></Container>
<db-container title="标准组件良率" icon="std"></db-container> <Container title="标准组件良率" icon="std"></Container>
<db-container title="芯片OEE" icon="chip"></db-container> <Container title="芯片OEE" icon="chip"></Container>
<db-container title="转化效率" icon="cube"></db-container> <Container title="转化效率" icon="cube"></Container>
</div> </div>
</template> </template>
<script> <script>
import Container from "../../dashboard/components/Container.vue"; import Container from "@/views/copilot/components/Container.vue";
export default { export default {
name: "EfficiencyCopilot", name: "EfficiencyCopilot",
components: { DbContainer: Container }, components: { Container },
props: {
period: {
type: String,
default: "日",
},
},
data() { data() {
return {}; return {};
}, },
computed: {}, watch: {
methods: {}, period: {
handler(val) {
val && this.fetchData(val);
},
immediate: true,
},
},
methods: {
fetchData(period = "日") {
console.log(`效率驾驶舱,获取${period}数据`);
this.$store.dispatch("copilot/initCopilot", { period, source: "efficiency" });
},
},
}; };
</script> </script>