初始化网系分类和故障分类
This commit is contained in:
parent
1cfa22e286
commit
4f0183b6b9
|
@ -53,7 +53,7 @@ export class GenDevService {
|
||||||
EventBus.emit('genDataEvent', { type: 'end' });
|
EventBus.emit('genDataEvent', { type: 'end' });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initializeDeviceSystemType() {
|
public async initializeDeviceSystemType() {
|
||||||
this.logger.log('初始化设备分类');
|
this.logger.log('初始化设备分类');
|
||||||
// 创建网系类别分类
|
// 创建网系类别分类
|
||||||
let systemTypeTaxonomy = await db.taxonomy.findFirst({
|
let systemTypeTaxonomy = await db.taxonomy.findFirst({
|
||||||
|
@ -62,7 +62,7 @@ export class GenDevService {
|
||||||
if (!systemTypeTaxonomy) {
|
if (!systemTypeTaxonomy) {
|
||||||
systemTypeTaxonomy = await db.taxonomy.create({
|
systemTypeTaxonomy = await db.taxonomy.create({
|
||||||
data: {
|
data: {
|
||||||
name: '网系类别',
|
name: '网系类型',
|
||||||
slug: 'system_type',
|
slug: 'system_type',
|
||||||
objectType: ['device'],
|
objectType: ['device'],
|
||||||
},
|
},
|
||||||
|
@ -87,57 +87,57 @@ export class GenDevService {
|
||||||
|
|
||||||
// 定义网系类别
|
// 定义网系类别
|
||||||
const systemTypes = [
|
const systemTypes = [
|
||||||
{
|
// {
|
||||||
name: '文印系统',
|
// name: '文印系统',
|
||||||
children: [
|
// children: [
|
||||||
'电源故障',
|
// '电源故障',
|
||||||
'主板故障',
|
// '主板故障',
|
||||||
'内存故障',
|
// '内存故障',
|
||||||
'硬盘故障',
|
// '硬盘故障',
|
||||||
'显示器故障',
|
// '显示器故障',
|
||||||
'键盘故障',
|
// '键盘故障',
|
||||||
'鼠标故障',
|
// '鼠标故障',
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: '内网系统',
|
// name: '内网系统',
|
||||||
children: [
|
// children: [
|
||||||
'系统崩溃',
|
// '系统崩溃',
|
||||||
'应用程序错误',
|
// '应用程序错误',
|
||||||
'病毒感染',
|
// '病毒感染',
|
||||||
'驱动问题',
|
// '驱动问题',
|
||||||
'系统更新失败',
|
// '系统更新失败',
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'Windows系统',
|
// name: 'Windows系统',
|
||||||
children: [
|
// children: [
|
||||||
'系统响应慢',
|
// '系统响应慢',
|
||||||
'资源占用过高',
|
// '资源占用过高',
|
||||||
'过热',
|
// '过热',
|
||||||
'电池寿命短',
|
// '电池寿命短',
|
||||||
'存储空间不足',
|
// '存储空间不足',
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'Linux系统',
|
// name: 'Linux系统',
|
||||||
children: ['未知错误', '用户操作错误', '环境因素', '设备老化'],
|
// children: ['未知错误', '用户操作错误', '环境因素', '设备老化'],
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: '移动设备系统',
|
// name: '移动设备系统',
|
||||||
children: ['参数设置错误', '配置文件损坏', '兼容性问题', '初始化失败'],
|
// children: ['参数设置错误', '配置文件损坏', '兼容性问题', '初始化失败'],
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
// 定义安防设备的子类型
|
// 定义安防设备的子类型
|
||||||
const securityDevices = {
|
const securityDevices = {
|
||||||
未知错误: [
|
// 未知错误: [
|
||||||
'未授权访问',
|
// '未授权访问',
|
||||||
'数据泄露',
|
// '数据泄露',
|
||||||
'密码重置',
|
// '密码重置',
|
||||||
'权限异常',
|
// '权限异常',
|
||||||
'安全策略冲突',
|
// '安全策略冲突',
|
||||||
],
|
// ],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 创建网系类别及其关联的设备类型
|
// 创建网系类别及其关联的设备类型
|
||||||
|
|
|
@ -146,7 +146,13 @@ export class InitService {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('Minio initialization failed:', 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') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
try {
|
try {
|
||||||
await this.genDevService.genDataEvent();
|
await this.genDevService.genDataEvent();
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
Col,
|
Col,
|
||||||
Typography,
|
Typography,
|
||||||
Divider,
|
Divider,
|
||||||
|
message,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import { api } from "@nice/client";
|
import { api } from "@nice/client";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
|
@ -260,7 +261,14 @@ export default function DeviceManager({ title }: TermManagerProps) {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: "确认删除",
|
title: "确认删除",
|
||||||
content: `确定要删除"${term.name}"吗?这将同时删除其下所有子项!`,
|
content: `确定要删除"${term.name}"吗?这将同时删除其下所有子项!`,
|
||||||
onOk: () => softDeleteByIds({ ids: [term.id] }),
|
onOk: () => softDeleteByIds({ ids: [term.id] },{
|
||||||
|
onSuccess: () => {
|
||||||
|
message.success("删除成功");
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
message.error("删除失败");
|
||||||
|
},
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
refetchSystemType();
|
refetchSystemType();
|
||||||
refetchDeviceType();
|
refetchDeviceType();
|
||||||
|
@ -278,6 +286,7 @@ export default function DeviceManager({ title }: TermManagerProps) {
|
||||||
hasChildren: editingTerm.hasChildren,
|
hasChildren: editingTerm.hasChildren,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
message.success("修改成功");
|
||||||
} else {
|
} else {
|
||||||
createTerm({
|
createTerm({
|
||||||
data: {
|
data: {
|
||||||
|
@ -286,6 +295,7 @@ export default function DeviceManager({ title }: TermManagerProps) {
|
||||||
parentId: parentId,
|
parentId: parentId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
message.success("添加成功");
|
||||||
}
|
}
|
||||||
refetchSystemType();
|
refetchSystemType();
|
||||||
refetchDeviceType();
|
refetchDeviceType();
|
||||||
|
|
Loading…
Reference in New Issue