初始化网系分类和故障分类

This commit is contained in:
Li1304553726 2025-05-29 20:42:52 +08:00
parent 1cfa22e286
commit 4f0183b6b9
4 changed files with 67 additions and 51 deletions

View File

@ -53,7 +53,7 @@ export class GenDevService {
EventBus.emit('genDataEvent', { type: 'end' });
}
private async initializeDeviceSystemType() {
public async initializeDeviceSystemType() {
this.logger.log('初始化设备分类');
// 创建网系类别分类
let systemTypeTaxonomy = await db.taxonomy.findFirst({
@ -62,7 +62,7 @@ export class GenDevService {
if (!systemTypeTaxonomy) {
systemTypeTaxonomy = await db.taxonomy.create({
data: {
name: '网系类',
name: '网系类',
slug: 'system_type',
objectType: ['device'],
},
@ -87,57 +87,57 @@ export class GenDevService {
// 定义网系类别
const systemTypes = [
{
name: '文印系统',
children: [
'电源故障',
'主板故障',
'内存故障',
'硬盘故障',
'显示器故障',
'键盘故障',
'鼠标故障',
],
},
{
name: '内网系统',
children: [
'系统崩溃',
'应用程序错误',
'病毒感染',
'驱动问题',
'系统更新失败',
],
},
{
name: 'Windows系统',
children: [
'系统响应慢',
'资源占用过高',
'过热',
'电池寿命短',
'存储空间不足',
],
},
{
name: 'Linux系统',
children: ['未知错误', '用户操作错误', '环境因素', '设备老化'],
},
{
name: '移动设备系统',
children: ['参数设置错误', '配置文件损坏', '兼容性问题', '初始化失败'],
},
// {
// name: '文印系统',
// children: [
// '电源故障',
// '主板故障',
// '内存故障',
// '硬盘故障',
// '显示器故障',
// '键盘故障',
// '鼠标故障',
// ],
// },
// {
// name: '内网系统',
// children: [
// '系统崩溃',
// '应用程序错误',
// '病毒感染',
// '驱动问题',
// '系统更新失败',
// ],
// },
// {
// name: 'Windows系统',
// children: [
// '系统响应慢',
// '资源占用过高',
// '过热',
// '电池寿命短',
// '存储空间不足',
// ],
// },
// {
// name: 'Linux系统',
// children: ['未知错误', '用户操作错误', '环境因素', '设备老化'],
// },
// {
// name: '移动设备系统',
// children: ['参数设置错误', '配置文件损坏', '兼容性问题', '初始化失败'],
// },
];
// 定义安防设备的子类型
const securityDevices = {
: [
'未授权访问',
'数据泄露',
'密码重置',
'权限异常',
'安全策略冲突',
],
// 未知错误: [
// '未授权访问',
// '数据泄露',
// '密码重置',
// '权限异常',
// '安全策略冲突',
// ],
};
// 创建网系类别及其关联的设备类型

View File

@ -146,7 +146,13 @@ export class InitService {
} catch (error) {
this.logger.error('Minio initialization failed:', error);
}
// 修改这里:在生产环境也初始化设备分类数据
try {
this.logger.log('Initializing device system types...');
await this.genDevService.initializeDeviceSystemType();
} catch (error) {
this.logger.error('Device system type initialization failed:', error);
}
if (process.env.NODE_ENV === 'development') {
try {
await this.genDevService.genDataEvent();

0
apps/web/index.html Normal file → Executable file
View File

View File

@ -12,6 +12,7 @@ import {
Col,
Typography,
Divider,
message,
} from "antd";
import { api } from "@nice/client";
import { useState, useEffect } from "react";
@ -260,7 +261,14 @@ export default function DeviceManager({ title }: TermManagerProps) {
Modal.confirm({
title: "确认删除",
content: `确定要删除"${term.name}"吗?这将同时删除其下所有子项!`,
onOk: () => softDeleteByIds({ ids: [term.id] }),
onOk: () => softDeleteByIds({ ids: [term.id] },{
onSuccess: () => {
message.success("删除成功");
},
onError: () => {
message.error("删除失败");
},
}),
});
refetchSystemType();
refetchDeviceType();
@ -278,6 +286,7 @@ export default function DeviceManager({ title }: TermManagerProps) {
hasChildren: editingTerm.hasChildren,
},
});
message.success("修改成功");
} else {
createTerm({
data: {
@ -286,6 +295,7 @@ export default function DeviceManager({ title }: TermManagerProps) {
parentId: parentId,
},
});
message.success("添加成功");
}
refetchSystemType();
refetchDeviceType();