diff --git a/.env.dev b/.env.dev index f62007f..95ef7e2 100644 --- a/.env.dev +++ b/.env.dev @@ -1,3 +1,10 @@ +### + # @Author: zhp + # @Date: 2024-04-28 13:42:51 + # @LastEditTime: 2024-05-08 08:57:33 + # @LastEditors: zhp + # @Description: +### # 开发环境配置 ENV = 'development' diff --git a/src/api/cost/index.js b/src/api/cost/index.js new file mode 100644 index 0000000..2fa3a7e --- /dev/null +++ b/src/api/cost/index.js @@ -0,0 +1,32 @@ +/* + * @Author: zhp + * @Date: 2024-04-26 14:53:45 + * @LastEditTime: 2024-05-06 14:55:33 + * @LastEditors: zhp + * @Description: + */ +import request from '@/utils/request' + +// 查询部门列表 +export function getOrderList(data) { + return request({ + url: 'ip/prod-order/prodOrderList', + method: 'post', + data: data + }) +} +export function getCostPage(data) { + return request({ + url: 'ip/cost/costPage', + method: 'post', + data: data + }) +} + +export function getCostList(data) { + return request({ + url: 'ip/cost/costList', + method: 'post', + data: data + }) +} diff --git a/src/api/energy/index.js b/src/api/energy/index.js new file mode 100644 index 0000000..b96d2fa --- /dev/null +++ b/src/api/energy/index.js @@ -0,0 +1,15 @@ +/* + * @Author: zhp + * @Date: 2024-04-28 09:28:12 + * @LastEditTime: 2024-04-28 09:43:40 + * @LastEditors: zhp + * @Description: + */ +import request from '@/utils/request' +export function getEnergyPage(data) { + return request({ + url: 'ip/energy/page', + method: 'post', + data: data + }) +} diff --git a/src/api/greenest/index.js b/src/api/greenest/index.js new file mode 100644 index 0000000..53abfbe --- /dev/null +++ b/src/api/greenest/index.js @@ -0,0 +1,32 @@ +/* + * @Author: zhp + * @Date: 2024-04-26 14:53:45 + * @LastEditTime: 2024-05-06 14:53:04 + * @LastEditors: zhp + * @Description: + */ +import request from '@/utils/request' + +// 查询部门列表 +export function getOrderList(data) { + return request({ + url: 'ip/prod-order/prodOrderList', + method: 'post', + data: data + }) +} +export function getEpPage(data) { + return request({ + url: 'ip/environment-protection/environmentPage', + method: 'post', + data: data + }) +} + +export function getCostList(data) { + return request({ + url: 'ip/cost/costList', + method: 'post', + data: data + }) +} diff --git a/src/api/produceData/index.js b/src/api/produceData/index.js new file mode 100644 index 0000000..3df70d9 --- /dev/null +++ b/src/api/produceData/index.js @@ -0,0 +1,32 @@ +/* + * @Author: zhp + * @Date: 2024-05-07 08:54:59 + * @LastEditTime: 2024-05-07 09:34:17 + * @LastEditors: zhp + * @Description: + */ +/* + * @Author: zhp + * @Date: 2024-04-26 14:53:45 + * @LastEditTime: 2024-05-06 14:53:04 + * @LastEditors: zhp + * @Description: + */ +import request from '@/utils/request' + +// 查询部门列表 +export function getProduceDataPage(data) { + return request({ + url: 'ip/prod-output/prodOutputDataPage', + method: 'post', + data: data + }) +} + +export function getProduceDataDetail(data){ + return request({ + url: '/ip/prod-output/get=' + id, + method: 'get', + query: data + }) +} diff --git a/src/api/wareHouse/index.js b/src/api/wareHouse/index.js new file mode 100644 index 0000000..b34ea5b --- /dev/null +++ b/src/api/wareHouse/index.js @@ -0,0 +1,15 @@ +/* + * @Author: zhp + * @Date: 2024-04-28 09:28:12 + * @LastEditTime: 2024-04-28 15:52:36 + * @LastEditors: zhp + * @Description: + */ +import request from '@/utils/request' +export function getStockPage(data) { + return request({ + url: 'ip/stock/page', + method: 'post', + data: data + }) +} diff --git a/src/assets/images/homeindex/flash-icon.png b/src/assets/images/homeindex/flash-icon.png new file mode 100644 index 0000000..14e31ae Binary files /dev/null and b/src/assets/images/homeindex/flash-icon.png differ diff --git a/src/assets/images/homeindex/gas-icon.png b/src/assets/images/homeindex/gas-icon.png new file mode 100644 index 0000000..fdcac2e Binary files /dev/null and b/src/assets/images/homeindex/gas-icon.png differ diff --git a/src/assets/images/homeindex/ware-icon.png b/src/assets/images/homeindex/ware-icon.png new file mode 100644 index 0000000..5f746f0 Binary files /dev/null and b/src/assets/images/homeindex/ware-icon.png differ diff --git a/src/assets/images/homeindex/water-icon.png b/src/assets/images/homeindex/water-icon.png new file mode 100644 index 0000000..d89f955 Binary files /dev/null and b/src/assets/images/homeindex/water-icon.png differ diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue index 324b6e3..44fc12f 100644 --- a/src/layout/components/AppMain.vue +++ b/src/layout/components/AppMain.vue @@ -1,7 +1,7 @@ diff --git a/src/mixins/code-filter.js b/src/mixins/code-filter.js new file mode 100644 index 0000000..08cf4bd --- /dev/null +++ b/src/mixins/code-filter.js @@ -0,0 +1,87 @@ +/* + * @Author: zhp + * @Date: 2024-04-28 15:18:21 + * @LastEditTime: 2024-04-28 15:18:21 + * @LastEditors: zhp + * @Description: + */ + +/* + * @Date: 2020-12-29 16:49:28 + * @LastEditors: DY + * @LastEditTime: 2024-02-23 14:50:22 + * @FilePath: \basic-admin\src\filters\basicData\index.js + * @Description: + */ + +const table = { + lineStatus: { + 1: '生产中', + 2: '停止', + 3: '未知', + }, + reportType: { + 1: '日', + 2: '周', + 3: '月' + } +} + +// 日期格式化 +export function parseTime(time, pattern) { + if (arguments.length === 0 || !time) { + return null + } + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'object') { + date = time + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } else if (typeof time === 'string') { + time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm),''); + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + date = new Date(time) + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + } + const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { + return ['日', '一', '二', '三', '四', '五', '六'][value] + } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str +} + +export function toDay(time) { + if (time < 24) { + return time + '小时' + } else { + const day = ~~(time / 24) + const hour = time % 24 + return day + '天' + hour + '小时' + } +} + +export default function (dictTable) { + return function (val) { + return table?.[dictTable]?.[val] + } +} diff --git a/src/store/modules/home.js b/src/store/modules/home.js index ca92d85..56b3e64 100644 --- a/src/store/modules/home.js +++ b/src/store/modules/home.js @@ -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,8 +121,104 @@ 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) { for (const factory of factoryListResponse) { @@ -150,8 +278,57 @@ function getFactoryTargetValue(targetList, factoryId) { } /** - * - * @returns 初始化状态值 + * 获取 芯片良率目标值 和 标准组件良率目标值 + * @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 初始化 效率模块里 初始状态值 + */ +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; } @@ -254,10 +431,10 @@ async function doFetch(copilot_module = "yield", fetch_target, params) { } /** - * + * * @param {*} period 日周月年1,2,3,4 * @param {*} target 是否获取目标数据 - * @returns + * @returns */ function getCopilotYield(period, target = false) { return getCopilotData("yield", period, target); diff --git a/src/views/copilot/yield/assets/icon.png b/src/views/copilot/assets/icon.png similarity index 100% rename from src/views/copilot/yield/assets/icon.png rename to src/views/copilot/assets/icon.png diff --git a/src/views/copilot/components/BarChartBase.vue b/src/views/copilot/components/BarChartBase.vue new file mode 100644 index 0000000..528cfd5 --- /dev/null +++ b/src/views/copilot/components/BarChartBase.vue @@ -0,0 +1,258 @@ + + + + + + + diff --git a/src/views/copilot/components/Container.vue b/src/views/copilot/components/Container.vue index 1e59c2c..cfeb685 100644 --- a/src/views/copilot/components/Container.vue +++ b/src/views/copilot/components/Container.vue @@ -1,14 +1,15 @@ -