瀏覽代碼

perf(views): 添加"算法管理"模块COP算法功能

wangshun 1 周之前
父節點
當前提交
1c09e21411
共有 4 個文件被更改,包括 103 次插入3 次删除
  1. 8 0
      src/api/index.ts
  2. 31 0
      src/types/index.ts
  3. 48 3
      src/views/algorithm-manage/AlgorithmEditing.vue
  4. 16 0
      src/views/algorithm-manage/AlgorithmManage.vue

+ 8 - 0
src/api/index.ts

@@ -33,6 +33,7 @@ import type {
   CoolingStatisticsResult,
   CustomParameters,
   DeviceBindQuery,
+  DeviceCop,
   DeviceGroup,
   DeviceGroupItem,
   DeviceGroupListQuery,
@@ -579,6 +580,13 @@ export const getDeviceListOptions = async (deviceId: number) => {
   return data;
 };
 
+export const updateDeviceCop = async (params: DeviceCop[]) => {
+  await request(apiBiz('/device/update'), {
+    method: 'POST',
+    body: JSON.stringify(params),
+  });
+};
+
 // 设备工况
 
 export const getDevWorkTypeCount = async (deviceGroupId: number, deviceTypes: number[]) => {

+ 31 - 0
src/types/index.ts

@@ -2104,6 +2104,31 @@ export interface AlgorithmConfigInfo extends AlgorithmForm {
   chilledWaterOutletTempRangeList: TemperatureRangeItem[];
   chilledWaterOutletTempRange?: string;
   chilledWaterOutletTempSet: string;
+  deviceCOPList: DeviceCopItem[];
+  deviceCopUpdateDTOS: { deviceId: number; enableCopSet: boolean }[];
+}
+
+export interface DeviceCopItem {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  deviceName: string;
+  groupId: number;
+  deviceType: number;
+  userId: number;
+  brand: string;
+  model: string;
+  productionDate: string;
+  status: number;
+  deleted: number;
+  runningStatus: number;
+  errorStatus: number;
+  orgId: number;
+  deviceDetail: string;
+  addingToAlg: boolean;
+  enableCopSet: boolean;
 }
 
 export interface OrgDeviceLimit {
@@ -2457,3 +2482,9 @@ export interface CharacterParams {
   roleName: string;
   orgId?: number;
 }
+
+export interface DeviceCop {
+  id: number;
+  enableCopSet: boolean;
+  deviceName?: string;
+}

+ 48 - 3
src/views/algorithm-manage/AlgorithmEditing.vue

@@ -14,7 +14,14 @@ import MonthSetting from './MonthSetting.vue';
 import SetInterval from './SetInterval.vue';
 
 import type { FormInstance, Rule } from 'ant-design-vue/es/form';
-import type { AlgorithmConfigInfo, AlgorithmForm, ChillersItem, TemperatureRange, TemperatureRangeItem } from '@/types';
+import type {
+  AlgorithmConfigInfo,
+  AlgorithmForm,
+  ChillersItem,
+  DeviceCop,
+  TemperatureRange,
+  TemperatureRangeItem,
+} from '@/types';
 
 const { dictData: algTempCtrlMinStep, getDictData: getAlgTempCtrlMinStep } = useDictData(DictCode.AlgTempCtrlMinStep);
 const { dictData: algTempHumCollectPeriod, getDictData: getAlgTempHumCollectPeriod } = useDictData(
@@ -46,6 +53,7 @@ const temperatureRangeList = ref<TemperatureRange[]>([]);
 const chillersList = ref<ChillersItem[]>([]);
 const algorithmId = ref<number>();
 const groupId = ref<number>();
+const deviceCopItem = ref<DeviceCop[]>([]);
 const algorithmForm = ref<AlgorithmForm>({
   enabled: false,
   sendCtrlCmd: true,
@@ -97,6 +105,7 @@ const rules: Record<string, Rule[]> = {
 const editorAlgorithmChange = (info: AlgorithmConfigInfo) => {
   temperatureRangeList.value = [];
   chillersList.value = [];
+  deviceCopItem.value = [];
   const {
     id: algId,
     enabled,
@@ -125,7 +134,17 @@ const editorAlgorithmChange = (info: AlgorithmConfigInfo) => {
     chilledWaterOutletTempRangeList,
     chilledWaterOutletTempSet,
     devGroupId,
+    deviceCOPList,
   } = info;
+  deviceCOPList.forEach((item) => {
+    const { id, enableCopSet, deviceName } = item;
+    deviceCopItem.value.push({
+      id,
+      enableCopSet,
+      deviceName,
+    });
+  });
+
   groupId.value = devGroupId;
   algorithmId.value = algId;
   Object.assign(algorithmForm.value, {
@@ -271,14 +290,23 @@ const addAlgorithm = async () => {
           upper,
         });
       });
-
+      const deviceCopList: { deviceId: number; enableCopSet: boolean }[] = [];
+      deviceCopItem.value.forEach((item) => {
+        const { id, enableCopSet } = item;
+        deviceCopList.push({
+          deviceId: id,
+          enableCopSet,
+        });
+      });
       await addAlgorithmConfigUpdate({
         ...algorithmForm.value,
         id: algorithmId.value,
         chillers: chillersList.value,
         chilledWaterOutletTempRangeList: timeList,
         chilledWaterOutletTempSet: monthSettingRefs.value ? monthSettingRefs.value.stringConversion() : '',
+        deviceCopUpdateDTOS: deviceCopList,
       });
+
       if (groupId.value) {
         emit('confirmClick', groupId.value);
       }
@@ -499,7 +527,7 @@ onMounted(() => {
               <ASwitch class="analysis-margin" v-model:checked="algorithmForm.analysis" />
               <div @click="analysisEditor" class="editor-style">{{ $t('common.editor') }}</div>
             </AFlex>
-            <AFlex align="center">
+            <AFlex align="center" class="system-functions">
               <div class="div-width">{{ $t('algorithmManage.dynamicAdjustment') }}</div>
               <AFlex align="center" class="adjustment-div">
                 <div class="adjustment-text">{{ $t('algorithmManage.freezingSetValue') }}</div>
@@ -509,6 +537,15 @@ onMounted(() => {
                 <div @click="setEditor" class="editor-style editor-left">{{ $t('common.editor') }}</div>
               </AFlex>
             </AFlex>
+            <AFlex align="center">
+              <div class="div-width">{{ t('algorithmManage.copAlgorithm') }}</div>
+              <AFlex align="center" class="adjustment-div" wrap="wrap">
+                <AFlex v-for="item in deviceCopItem" :key="item.id" class="adjustment-right">
+                  <div>{{ item.deviceName }}:&nbsp;&nbsp;&nbsp;</div>
+                  <ASwitch v-model:checked="item.enableCopSet" />
+                </AFlex>
+              </AFlex>
+            </AFlex>
           </div>
         </ACollapsePanel>
       </ACollapse>
@@ -586,6 +623,14 @@ onMounted(() => {
 </template>
 
 <style lang="scss" scoped>
+.system-functions {
+  margin-bottom: 16px;
+}
+
+.adjustment-right {
+  margin-right: 40px;
+}
+
 .button-width {
   width: 128px;
   height: 40px;

+ 16 - 0
src/views/algorithm-manage/AlgorithmManage.vue

@@ -258,6 +258,18 @@ const cancelClick = () => {
               </div>
             </AFlex>
           </AFlex>
+
+          <AFlex class="intelligent-style">
+            <div class="intelligent-width">{{ t('algorithmManage.copAlgorithm') }}</div>
+            <AFlex align="center" class="adjustment-div">
+              <AFlex v-for="item in algorithmConfigInfo?.deviceCOPList" :key="item.id" class="adjustment-right">
+                <div>{{ item.deviceName }}:&nbsp;&nbsp;&nbsp;</div>
+                <div>
+                  {{ item.enableCopSet ? t('common.open') : t('common.turnOff') }}
+                </div>
+              </AFlex>
+            </AFlex>
+          </AFlex>
         </ACollapsePanel>
       </ACollapse>
     </div>
@@ -269,6 +281,10 @@ const cancelClick = () => {
   width: 160px;
 }
 
+.adjustment-right {
+  margin-right: 40px;
+}
+
 .adjustment-left {
   margin-left: 40px;
 }