diff --git a/.env.development b/.env.development index 60a5716..6da8916 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ VITE_API_BASEURL = "https://ibms-cvilux-api.production.mjmtech.com.tw" VITE_FILE_API_BASEURL = "https://cgems.cvilux-group.com:8088" -VITE_MQTT_BASEURL = "ws://192.168.0.217:8083/mqtt" +VITE_MQTT_BASEURL = "wss://mqttwss.mjm-staging.developers-homelab.net" VITE_FORGE_BASEURL = "https://cgems.cvilux-group.com:8088/dist" \ No newline at end of file diff --git a/.env.production b/.env.production index cdbac13..6da8916 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,4 @@ VITE_API_BASEURL = "https://ibms-cvilux-api.production.mjmtech.com.tw" VITE_FILE_API_BASEURL = "https://cgems.cvilux-group.com:8088" -VITE_MQTT_BASEURL = "wss://192.168.0.217:8084/mqtt" +VITE_MQTT_BASEURL = "wss://mqttwss.mjm-staging.developers-homelab.net" VITE_FORGE_BASEURL = "https://cgems.cvilux-group.com:8088/dist" \ No newline at end of file diff --git a/src/apis/asset/api.js b/src/apis/asset/api.js index c65b683..94f08e1 100644 --- a/src/apis/asset/api.js +++ b/src/apis/asset/api.js @@ -20,6 +20,11 @@ export const GET_ASSET_IOT_LIST_API = `/AssetManage/GetIOTList`; export const GET_ASSET_SUB_POINT_API = `/AssetManage/GetSubPoint`; export const GET_ASSET_IOT_SCHEMA_API = `/AssetManage/GetResponseSchema`; +export const POST_ASSET_IOT_SCHEMA_API = `/AssetManage/SaveResponseSchema`; + +export const GET_ASSET_DEVICE_ITEM_API = `/AssetManage/GetDeviceItem`; +export const POST_ASSET_DEVICE_ITEM_API = `/AssetManage/SaveDeviceItem`; +export const DELETE_ASSET_DEVICE_ITEM_API = `/AssetManage/DeleteDeviceItem`; export const GET_ASSET_DEPARTMENT_API = `/AssetManage/GetDepartment`; export const POST_ASSET_DEPARTMENT_API = `/AssetManage/SaveDepartment`; @@ -28,3 +33,5 @@ export const DELETE_ASSET_DEPARTMENT_API = `/AssetManage/DeleteDepartment`; export const GET_ASSET_ELECTYPE_API = `/AssetManage/GetElecType`; export const POST_ASSET_ELECTYPE_API = `/AssetManage/SaveElecType`; export const DELETE_ASSET_ELECTYPE_API = `/AssetManage/DeleteElecType`; + +export const POST_ASSET_ELEC_SETTING_API = `/AssetManage/SaveAssetSetting`; \ No newline at end of file diff --git a/src/apis/asset/index.js b/src/apis/asset/index.js index 7b05cc5..12a3dc1 100644 --- a/src/apis/asset/index.js +++ b/src/apis/asset/index.js @@ -15,12 +15,17 @@ import { POST_ASSET_SINGLE_API, GET_ASSET_SUB_POINT_API, GET_ASSET_IOT_SCHEMA_API, + POST_ASSET_IOT_SCHEMA_API, + GET_ASSET_DEVICE_ITEM_API, + POST_ASSET_DEVICE_ITEM_API, + DELETE_ASSET_DEVICE_ITEM_API, GET_ASSET_DEPARTMENT_API, POST_ASSET_DEPARTMENT_API, DELETE_ASSET_DEPARTMENT_API, GET_ASSET_ELECTYPE_API, POST_ASSET_ELECTYPE_API, - DELETE_ASSET_ELECTYPE_API + DELETE_ASSET_ELECTYPE_API, + POST_ASSET_ELEC_SETTING_API, } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apihandler"; @@ -156,8 +161,8 @@ export const deleteAssetItem = async (main_id) => { }); }; -export const getAssetFloorList = async () => { - const res = await instance.post(GET_ASSET_FLOOR_LIST_API); +export const getAssetFloorList = async (building_guid) => { + const res = await instance.post(GET_ASSET_FLOOR_LIST_API, { building_guid }); return apihandler(res.code, res.data, { msg: res.msg, @@ -207,7 +212,63 @@ export const getAssetSubPoint = async (sub_system_tag) => { }; export const getIOTSchema = async (variable_id) => { - const res = await instance.post(GET_ASSET_IOT_SCHEMA_API, {variable_id}); + const res = await instance.post(GET_ASSET_IOT_SCHEMA_API, { variable_id }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const postIOTSchema = async ({ name, variable_id, points }) => { + const res = await instance.post(POST_ASSET_IOT_SCHEMA_API, { + name, + variable_id, + points, + }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const getDeviceItem = async (variable_id) => { + const res = await instance.post(GET_ASSET_DEVICE_ITEM_API, { variable_id }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const postDeviceItem = async ({ + id, + variable_id, + full_name, + points, + decimals, + is_bool, + is_link, +}) => { + const res = await instance.post(POST_ASSET_DEVICE_ITEM_API, { + id, + variable_id, + full_name, + points, + decimals, + is_bool, + is_link, + }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const deleteDeviceItem = async (id) => { + const res = await instance.post(DELETE_ASSET_DEVICE_ITEM_API, { id }); return apihandler(res.code, res.data, { msg: res.msg, @@ -273,4 +334,13 @@ export const deleteElecTypeItem = async (id) => { msg: res.msg, code: res.code, }); -}; \ No newline at end of file +}; + +export const postAssetElecSetting = async (formData) => { + const res = await instance.post(POST_ASSET_ELEC_SETTING_API, formData); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; diff --git a/src/apis/energy/index.js b/src/apis/energy/index.js index 3fb60c2..7bb4eba 100644 --- a/src/apis/energy/index.js +++ b/src/apis/energy/index.js @@ -11,14 +11,22 @@ import { GET_CARBON_API, POST_EDIT_CARBON_API, GET_TIME_ELEC_API, - POST_TIME_ELEC_API + POST_TIME_ELEC_API, } from "./api"; import instance, { fileInstance } from "@/util/request"; import apihandler from "@/util/apihandler"; import downloadExcel from "@/util/downloadExcel"; -export const getRealTimeDist = async () => { - const res = await instance.post(GET_REALTIME_DIST_API); +export const getRealTimeDist = async ({ + building_guid, + department_id_list, + floor_guid_list, +}) => { + const res = await instance.post(GET_REALTIME_DIST_API, { + building_guid, + department_id_list, + floor_guid_list, + }); return apihandler(res.code, res.data, { msg: res.msg, @@ -26,8 +34,16 @@ export const getRealTimeDist = async () => { }); }; -export const getElecUseDay = async () => { - const res = await instance.post(GET_ELECUSE_DAY_API); +export const getElecUseDay = async ({ + building_guid, + department_id_list, + floor_guid_list, +}) => { + const res = await instance.post(GET_ELECUSE_DAY_API,{ + building_guid, + department_id_list, + floor_guid_list, + }); return apihandler(res.code, res.data, { msg: res.msg, @@ -35,8 +51,18 @@ export const getElecUseDay = async () => { }); }; -export const getTaipower = async () => { - const res = await instance.post(GET_TAI_POWER_API); +export const getTaipower = async ({ + coefficient, + building_guid, + department_id_list, + floor_guid_list, +}) => { + const res = await instance.post(GET_TAI_POWER_API, { + coefficient, + building_guid, + department_id_list, + floor_guid_list, + }); return apihandler(res.code, res.data, { msg: res.msg, @@ -118,7 +144,7 @@ export const getExcel = async ({ }; export const getDemand = async (building_guid) => { - const res = await instance.post(GET_DEMAND_API, {building_guid}); + const res = await instance.post(GET_DEMAND_API, { building_guid }); return apihandler(res.code, res.data, { msg: res.msg, @@ -126,13 +152,19 @@ export const getDemand = async (building_guid) => { }); }; -export const postEditDemand = async ({ id, contract, alert, reset, building_guid }) => { +export const postEditDemand = async ({ + id, + contract, + alert, + reset, + building_guid, +}) => { const res = await instance.put(POST_EDIT_DEMAND_API, { id, contract, alert, reset, - building_guid + building_guid, }); return apihandler(res.code, res.data, { @@ -142,7 +174,7 @@ export const postEditDemand = async ({ id, contract, alert, reset, building_guid }; export const getCarbonValue = async (building_guid) => { - const res = await instance.post(GET_CARBON_API, {building_guid}); + const res = await instance.post(GET_CARBON_API, { building_guid }); return apihandler(res.code, res.data, { msg: res.msg, @@ -150,11 +182,15 @@ export const getCarbonValue = async (building_guid) => { }); }; -export const postEditCarbonValue = async ({ id, coefficient, building_guid }) => { +export const postEditCarbonValue = async ({ + id, + coefficient, + building_guid, +}) => { const res = await instance.put(POST_EDIT_CARBON_API, { id, coefficient, - building_guid + building_guid, }); return apihandler(res.code, res.data, { @@ -164,7 +200,7 @@ export const postEditCarbonValue = async ({ id, coefficient, building_guid }) => }; export const getTimeElec = async (building_guid) => { - const res = await instance.post(GET_TIME_ELEC_API, {building_guid}); + const res = await instance.post(GET_TIME_ELEC_API, { building_guid }); return apihandler(res.code, res.data, { msg: res.msg, @@ -174,9 +210,9 @@ export const getTimeElec = async (building_guid) => { export const postTimeElec = async ({ sheet, cost, building_guid }) => { const res = await instance.put(POST_TIME_ELEC_API, { - sheet, + sheet, cost, - building_guid + building_guid, }); return apihandler(res.code, res.data, { diff --git a/src/apis/history/index.js b/src/apis/history/index.js index 922bd7c..c393159 100644 --- a/src/apis/history/index.js +++ b/src/apis/history/index.js @@ -16,11 +16,13 @@ export const getHistorySideBar = async ({ sub_system_tag, department_id, elec_type_id, + building_guid, }) => { const res = await instance.post(GET_HISTORY_SIDEBAR_API, { sub_system_tag, department_id, elec_type_id, + building_guid, }); return apihandler(res.code, res.data, { diff --git a/src/components/navbar/NavbarBuilding.vue b/src/components/navbar/NavbarBuilding.vue index 5664ca7..7270901 100644 --- a/src/components/navbar/NavbarBuilding.vue +++ b/src/components/navbar/NavbarBuilding.vue @@ -6,6 +6,7 @@ const store = useBuildingStore(); const selectBuilding = (bui) => { store.selectedBuilding = bui; // 改變 selectedBuilding,watch 會自動更新資料 + localStorage.setItem("CviBuilding", JSON.stringify(bui)); }; onMounted(() => { diff --git a/src/config/cn.json b/src/config/cn.json index 81ec44f..aa4f7b9 100644 --- a/src/config/cn.json +++ b/src/config/cn.json @@ -27,7 +27,24 @@ "lastweek_electricity_consumption": "上周用电量", "one_hour": "1小时", "four_hour": "4小时", - "eight_hour": "8小时" + "eight_hour": "8小时", + "energy_ranking": "能耗排行", + "last_30_days_energy_trend": "近30天能耗趋势", + "today_energy_consumption": "本日能耗", + "this_month_energy_consumption": "本月能耗", + "relative_energy_consumption": "环比能耗", + "daily_relative_change": "日环比", + "weekly_relative_change": "周环比", + "monthly_relative_change": "月环比", + "yearly_relative_change": "年环比", + "today": "今日", + "yesterday": "昨日", + "this_week": "本周", + "last_week": "上周", + "this_month": "本月", + "last_month": "上月", + "this_year": "今年", + "last_year": "去年" }, "history": { "title": "历史资料", @@ -358,12 +375,29 @@ "confirm": "确认", "restore": "复原", "stop_edit": "停止修改", - "start_edit": "开始修改" + "start_edit": "开始修改", + "convert": "轉換" }, "msg": { "sure_to_delete": "是否确认删除该项目?", "sure_to_delete_permanent": "是否确认永久删除该项目?", "delete_success": "删除成功", "delete_failed": "删除失败" + }, + "setting": { + "MQTT_parse": "MQTT 解析", + "schema": "架构", + "point": "点位", + "description": "描述", + "IoT_point_name": "IoT 点位名称", + "IoT_point_code": "IoT 点位代号", + "number_of_decimal_places": "小数位数", + "boolean_value": "布林值", + "hide_point": "点位显示", + "schema_name": "架构名称", + "IoT_point_structure": "IoT点位结构", + "system_point_name": "系统点位名称", + "json_format_text": "请贴上 JSON 格式数据", + "json_click_text": "请在左侧输入JSON并点选转换按钮" } } diff --git a/src/config/tw.json b/src/config/tw.json index 64e3de3..3bf22d3 100644 --- a/src/config/tw.json +++ b/src/config/tw.json @@ -27,7 +27,24 @@ "lastweek_electricity_consumption": "上週用電量", "one_hour": "1小時", "four_hour": "4小時", - "eight_hour": "8小時" + "eight_hour": "8小時", + "energy_ranking": "能耗排行", + "last_30_days_energy_trend": "近30天能耗趨勢", + "today_energy_consumption": "本日能耗", + "this_month_energy_consumption": "本月能耗", + "relative_energy_consumption": "環比能耗", + "daily_relative_change": "日環比", + "weekly_relative_change": "周環比", + "monthly_relative_change": "月環比", + "yearly_relative_change": "年環比", + "today": "今日", + "yesterday": "昨日", + "this_week": "本周", + "last_week": "上周", + "this_month": "本月", + "last_month": "上月", + "this_year": "今年", + "last_year": "去年" }, "history": { "title": "歷史資料", @@ -102,12 +119,12 @@ "elec_price_list": "電價表", "residential": "住宅型", "standard": "標準型", - "simple_elec_price_two_stage":"簡易型時間電價二段式", - "simple_elec_price_three_stage":"簡易型時間電價三段式", - "classification":"分類", - "summer_months":"夏月", - "non_summer_months":"非夏月", - "time_outside_summer_months":"夏月以外的時間", + "simple_elec_price_two_stage": "簡易型時間電價二段式", + "simple_elec_price_three_stage": "簡易型時間電價三段式", + "classification": "分類", + "summer_months": "夏月", + "non_summer_months": "非夏月", + "time_outside_summer_months": "夏月以外的時間", "basic_elec_charge": "基本電費", "charged_per_household": "按戶計收", "per_household_month": "每戶每月", @@ -358,12 +375,29 @@ "confirm": "確認", "restore": "復原", "stop_edit": "停止修改", - "start_edit": "開始修改" + "start_edit": "開始修改", + "convert":"轉換" }, "msg": { "sure_to_delete": "是否確認刪除該項目?", "sure_to_delete_permanent": "是否確認永久刪除該項目?", "delete_success": "刪除成功", "delete_failed": "刪除失敗" + }, + "setting": { + "MQTT_parse": "MQTT 解析", + "schema":"架構", + "point":"點位", + "description":"描述", + "IoT_point_name":"IoT 點位名稱", + "IoT_point_code":"IoT 點位代號", + "number_of_decimal_places":"小數位數", + "boolean_value":"布林值", + "hide_point":"點位顯示", + "schema_name":"架構名稱", + "IoT_point_structure" :"IoT點位結構", + "system_point_name":"系統點位名稱", + "json_format_text": "請貼上 JSON 格式數據", + "json_click_text": "請在左側輸入JSON並點選轉換按鈕" } } diff --git a/src/config/us.json b/src/config/us.json index 8d9f962..29ee496 100644 --- a/src/config/us.json +++ b/src/config/us.json @@ -15,6 +15,37 @@ "description": "File size cannot exceed 10MB", "formats": "File formats" }, + "dashboard": { + "yesterday_today": "Yesterday / Today's", + "elec_consumption_comparison": "Electricity Consumption Comparison", + "elec_consumption_comparison_trend": "Electricity Consumption Comparison Trend", + "electricity_consumption": "electricity consumption", + "today_electricity_consumption": "Today’s electricity consumption", + "yesterday_electricity_consumption": "Yesterday’s electricity consumption", + "this_last_week": "This Week's / Last Week's", + "thisweek_electricity_consumption": "This week’s electricity consumption", + "lastweek_electricity_consumption": "Last week’s electricity consumption", + "one_hour": "1 hour", + "four_hour": "4 hour", + "eight_hour": "8 hour", + "energy_ranking": "Energy consumption ranking", + "last_30_days_energy_trend": "Energy consumption trend for the past 30 days", + "today_energy_consumption": "Today", + "this_month_energy_consumption": "This month", + "relative_energy_consumption": "Energy consumption trend", + "daily_relative_change": "Daily", + "weekly_relative_change": "Weekly", + "monthly_relative_change": "Monthly", + "yearly_relative_change": "Yearly", + "today": "Today", + "yesterday": "Yesterday", + "this_week": "This week", + "last_week": "Last week", + "this_month": "This month", + "last_month": "Last month", + "this_year": "This year", + "last_year": "Last year" + }, "history": { "title": "Historical Data", "building_name": "Building", @@ -33,20 +64,6 @@ "end_date": "End date", "end_time": "End time" }, - "dashboard": { - "yesterday_today": "Yesterday / Today's", - "elec_consumption_comparison": "Electricity Consumption Comparison", - "elec_consumption_comparison_trend": "Electricity Consumption Comparison Trend", - "electricity_consumption": "electricity consumption", - "today_electricity_consumption": "Today’s electricity consumption", - "yesterday_electricity_consumption": "Yesterday’s electricity consumption", - "this_last_week": "This Week's / Last Week's", - "thisweek_electricity_consumption": "This week’s electricity consumption", - "lastweek_electricity_consumption": "Last week’s electricity consumption", - "one_hour": "1 hour", - "four_hour": "4 hour", - "eight_hour": "8 hour" - }, "system": { "status": "Status", "details": "Details", @@ -358,12 +375,29 @@ "confirm": "Confirm", "restore": "Restore", "stop_edit": "Stop editing", - "start_edit": "Start editing" + "start_edit": "Start editing", + "convert": "Convert" }, "msg": { "sure_to_delete": "Are you sure to delete this item?", "sure_to_delete_permanent": "Are you sure you want to permanently delete this item?", "delete_success": "Delete successfully", "delete_failed": "Delete failed" + }, + "setting": { + "MQTT_parse": "MQTT Parse", + "schema": "Schema", + "point": "Point", + "description": "Description", + "IoT_point_name": "IoT Point Name", + "IoT_point_code": "IoT Point Code", + "number_of_decimal_places": "Number of Decimal Places", + "boolean_value": "Boolean Value", + "hide_point": "Point Display", + "schema_name": "Schema name", + "IoT_point_structure": "IoT Point Structure", + "system_point_name": "System Point Name", + "json_format_text": "Please paste JSON format data", + "json_click_text": "Please enter JSON on the left and click the conversion button" } } diff --git a/src/fontawsomeIconRegister.js b/src/fontawsomeIconRegister.js index 9939954..3758302 100644 --- a/src/fontawsomeIconRegister.js +++ b/src/fontawsomeIconRegister.js @@ -61,8 +61,11 @@ import { faDownload, faStream, faSave, - faCrown + faCrown, + faClock, + faCheckCircle } from "@fortawesome/free-solid-svg-icons"; +import { faCircle } from "@fortawesome/free-regular-svg-icons"; /* add icons to the library */ library.add( @@ -124,7 +127,10 @@ library.add( faDownload, faStream, faSave, - faCrown + faCrown, + faClock, + faCheckCircle, + faCircle ); export default library; diff --git a/src/stores/useBuildingStore.js b/src/stores/useBuildingStore.js index 6f9c69d..94d2787 100644 --- a/src/stores/useBuildingStore.js +++ b/src/stores/useBuildingStore.js @@ -48,13 +48,14 @@ const useBuildingStore = defineStore("buildingInfo", () => { const res = await getBuildings(); buildings.value = res.data; if (res.data.length > 0 && !selectedBuilding.value) { - selectedBuilding.value = res.data[0]; // 預設選第一個建築 + const storedBuilding = JSON.parse(localStorage.getItem("CviBuilding")); + selectedBuilding.value = storedBuilding || res.data[0]; // 預設選第一個建築 } }; // 獲取樓層資料 - const fetchFloorList = async () => { - const res = await getAssetFloorList(); + const fetchFloorList = async (building_guid) => { + const res = await getAssetFloorList(building_guid); floorList.value = res.data[0]?.floors.map((d) => ({ ...d, title: d.full_name, @@ -75,7 +76,7 @@ const useBuildingStore = defineStore("buildingInfo", () => { // 當 selectedBuilding 改變時,更新 floorList 和 deptList watch(selectedBuilding, async (newBuilding) => { if (newBuilding) { - await Promise.all([fetchFloorList(), fetchDepartmentList()]); + await Promise.all([fetchFloorList(newBuilding.building_guid), fetchDepartmentList()]); } }); diff --git a/src/views/AssetManagement/AssetManagement.vue b/src/views/AssetManagement/AssetManagement.vue index 38d2b9e..acf2863 100644 --- a/src/views/AssetManagement/AssetManagement.vue +++ b/src/views/AssetManagement/AssetManagement.vue @@ -1,5 +1,5 @@