From 45b4f526d7851a20b1644a3381e6b349faa1a101 Mon Sep 17 00:00:00 2001 From: Sake <1246665453@qq.com> Date: Wed, 28 Jan 2026 14:00:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=91=8A=E8=AD=A6=E6=A3=80?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- domain/version/versionapi/api.go | 4 +- internal/app/app.go | 2 +- internal/core/vqd/model.go | 2 + internal/core/vqd/vqdalarm.go | 19 ++++++++- internal/core/vqd/vqdalarm.param.go | 2 + internal/core/vqdtask/core.go | 5 +++ pkg/vqdcms/mode.go | 1 + pkg/vqdcms/vqd.go | 25 +++++++++++- web/src/components/AddVqdTask.tsx | 4 +- web/src/components/VqdAlarm.tsx | 53 ++++++++++++++++++-------- web/src/components/VqdTask.tsx | 6 +-- web/src/components/VqdTimeTemplate.tsx | 4 +- web/src/components/channel/Channel.tsx | 2 +- web/src/pages/Home.tsx | 14 +++---- web/src/types/vqdalarm.ts | 4 ++ 16 files changed, 111 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index e156d7a..0bd2294 100644 --- a/Makefile +++ b/Makefile @@ -187,7 +187,7 @@ pack/windows: $(eval dir := $(BUILD_DIR_ROOT)/windows_amd64) @cp -r deploy/easyvqd/* $(dir) @cp -r deploy/win/ $(dir)/VqdSDK/ - @cp -r deploy/conf/* $(dir)/configs/ + @cp -r deploy/conf/ $(dir)/configs/ @cp -r *dll $(dir) @mv $(dir)/bin $(dir)/easyvqd.exe @upx $(dir)/easyvqd.exe diff --git a/domain/version/versionapi/api.go b/domain/version/versionapi/api.go index 367fa84..0d559e6 100644 --- a/domain/version/versionapi/api.go +++ b/domain/version/versionapi/api.go @@ -12,8 +12,8 @@ import ( // 通过修改版本号,来控制是否执行表迁移 var ( - DBVersion = "0.0.20" - DBRemark = "增加同步记录表" + DBVersion = "0.0.21" + DBRemark = "添加告警查询字段" ) // NewVersionCore ... diff --git a/internal/app/app.go b/internal/app/app.go index 59ada6f..cc15063 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -49,7 +49,7 @@ func Run(bc *conf.Bootstrap) { server.ReadTimeout(bc.Server.HTTP.Timeout.Duration()), server.WriteTimeout(bc.Server.HTTP.Timeout.Duration()), ) - lis, err := net.Listen("tcp", ":") + lis, err := net.Listen("tcp", ":8089") if err != nil { fmt.Printf("创建监听器失败: %v\n", err) return diff --git a/internal/core/vqd/model.go b/internal/core/vqd/model.go index d4d9df6..120e080 100644 --- a/internal/core/vqd/model.go +++ b/internal/core/vqd/model.go @@ -255,6 +255,7 @@ func (*VqdTimeTemplate) TableName() string { type Abnormal struct { Value float32 `json:"value"` Name string `json:"name"` + Mode string `json:"mode"` } type Abnormals []Abnormal @@ -294,6 +295,7 @@ type VqdAlarm struct { TaskID int64 `gorm:"column:task_id;notNull;default:0;comment:关联任务" json:"task_id"` // 关联任务名称 TaskName string `gorm:"column:task_name;notNull;default:'';comment:关联任务名称" json:"task_name"` // 任务名称 FilePath string `gorm:"column:file_path;notNull;default:'';comment:文件路径" json:"file_path"` // 文件路径 + AbnormalStr string `gorm:"column:abnormal_str;notNull;default:'';comment:类型" json:"abnormal_str"` // 文件路径 Abnormals Abnormals `gorm:"column:abnormals;type:jsonb;notNull;default:'{}';comment:告警异常列表" json:"abnormals"` // 告警异常列表 DefaultValues DefaultValues `gorm:"column:default_values;type:jsonb;notNull;default:'{}';comment:设置的默认阈值" json:"default_values"` // 设置的默认阈值 } diff --git a/internal/core/vqd/vqdalarm.go b/internal/core/vqd/vqdalarm.go index d8c5fbf..aa642c7 100644 --- a/internal/core/vqd/vqdalarm.go +++ b/internal/core/vqd/vqdalarm.go @@ -34,9 +34,26 @@ func (c Core) FindVqdAlarmAll() ([]*VqdAlarm, int64, error) { // FindVqdAlarm Paginated search func (c Core) FindVqdAlarm(ctx context.Context, in *FindVqdAlarmInput) ([]*VqdAlarm, int64, error) { items := make([]*VqdAlarm, 0) + if in.Mode != "" && in.Name != "" { + query := orm.NewQuery(8). + Where("abnormal_str like ? AND task_name like ? ", "%"+in.Mode+"%", "%"+in.Name+"%").OrderBy("created_at DESC") + total, err := c.store.VqdAlarm().Find(ctx, &items, in, query.Encode()...) + if err != nil { + return nil, 0, reason.ErrDB.Withf(`Find err[%s]`, err.Error()) + } + return items, total, nil + } if in.Name != "" { query := orm.NewQuery(8). - Where("channel_name like ? OR channel_id like ? OR channel_name like ? OR plan_name like ? OR task_template_name like ? OR task_name like ? ", "%"+in.Name+"%", "%"+in.Name+"%", "%"+in.Name+"%", "%"+in.Name+"%", "%"+in.Name+"%", "%"+in.Name+"%").OrderBy("created_at DESC") + Where("task_name like ? ", "%"+in.Name+"%").OrderBy("created_at DESC") + total, err := c.store.VqdAlarm().Find(ctx, &items, in, query.Encode()...) + if err != nil { + return nil, 0, reason.ErrDB.Withf(`Find err[%s]`, err.Error()) + } + return items, total, nil + } else if in.Mode != "" { + query := orm.NewQuery(8). + Where(`abnormal_str like ?`, "%"+in.Mode+"%").OrderBy("created_at DESC") total, err := c.store.VqdAlarm().Find(ctx, &items, in, query.Encode()...) if err != nil { return nil, 0, reason.ErrDB.Withf(`Find err[%s]`, err.Error()) diff --git a/internal/core/vqd/vqdalarm.param.go b/internal/core/vqd/vqdalarm.param.go index bf313be..aae2f0f 100644 --- a/internal/core/vqd/vqdalarm.param.go +++ b/internal/core/vqd/vqdalarm.param.go @@ -8,6 +8,7 @@ import ( type FindVqdAlarmInput struct { web.PagerFilter Name string `form:"name"` // 名称 + Mode string `form:"mode"` // 类型 } type EditVqdAlarmInput struct { @@ -24,6 +25,7 @@ type AddVqdAlarmInput struct { TaskID int64 `json:"task_id"` // 关联任务名称 TaskName string `json:"task_name"` // 任务名称 FilePath string `json:"file_path"` // 文件路径 + AbnormalStr string `json:"abnormal_str"` // 异常类型 IsDeep bool `json:"is_deep"` Abnormals Abnormals `json:"abnormals"` // 告警异常列表 DefaultValues DefaultValues `json:"default_values"` // 设置的默认阈值 diff --git a/internal/core/vqdtask/core.go b/internal/core/vqdtask/core.go index 8262f9c..94b09de 100644 --- a/internal/core/vqdtask/core.go +++ b/internal/core/vqdtask/core.go @@ -37,6 +37,7 @@ func NewCore(HostCore *host.Core, VqdTaskCore *vqd.Core, Cfg *conf.Bootstrap) *C in := &vqd.AddVqdAlarmInput{ ChannelName: v.ChannelName, + ChannelID: v.ChannelID, TaskTemplateName: v.TemplateName, TaskName: v.TaskName, PlanName: v.PlanName, @@ -47,15 +48,19 @@ func NewCore(HostCore *host.Core, VqdTaskCore *vqd.Core, Cfg *conf.Bootstrap) *C FilePath: v.FilePath, } var Abnormals vqd.Abnormals + var AbnormalStr []string if len(v.Abnormals) > 0 { for _, abnormal := range v.Abnormals { item := vqd.Abnormal{ Value: abnormal.Value, Name: abnormal.Name, + Mode: abnormal.Mode, } + AbnormalStr = append(AbnormalStr, abnormal.Mode) Abnormals = append(Abnormals, item) } } + in.AbnormalStr = strings.Join(AbnormalStr, ",") in.Abnormals = Abnormals var DefaultValues vqd.DefaultValues diff --git a/pkg/vqdcms/mode.go b/pkg/vqdcms/mode.go index 1be0304..01c44f8 100644 --- a/pkg/vqdcms/mode.go +++ b/pkg/vqdcms/mode.go @@ -12,6 +12,7 @@ const VQD_IMAGES_DIR = "snap" type Abnormal struct { Value float32 `json:"value"` Name string `json:"name"` + Mode string `json:"mode"` } type abnormal []Abnormal diff --git a/pkg/vqdcms/vqd.go b/pkg/vqdcms/vqd.go index 0ad2ead..96e0fd9 100644 --- a/pkg/vqdcms/vqd.go +++ b/pkg/vqdcms/vqd.go @@ -129,7 +129,7 @@ func (v *VQDHandle) Play() { //slog.Info("vqd cms play", "taskId", v.TaskID, "chnId", v.ChnID) _, errs := v.hostCore.Play(context.TODO(), &host.PlayInput{ ChannelID: v.info.ChannelID, - ActiveSecond: 0, + ActiveSecond: 40, }) if errs != nil { slog.Debug("vqd cms play", "taskId", v.info.TaskID, "chnId", v.info.ChannelID, "err", errs) @@ -244,6 +244,17 @@ func (v *VQDHandle) RunFrame() { } } +// VQD_ENABLE_COLOR = "vqd_color" +// VQD_ENABLE_LGTDARK = "vqd_lgt_dark" +// VQD_ENABLE_CLARITY = "vqd_clarity" +// VQD_ENABLE_NOISE = "vqd_noise" +// VQD_ENABLE_CONTRAST = "vqd_contrast" +// VQD_ENABLE_OCCLUSION = "vqd_occlusion" +// VQD_ENABLE_BLUE = "vqd_blue" +// VQD_ENABLE_SHARK = "vqd_shark" +// VQD_ENABLE_FREEZE = "vqd_freeze" +// VQD_ENABLE_MOSAIC = "vqd_mosaic" +// VQD_ENABLE_FLOWER = "vqd_flower" func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { isabnormal := false abnormals := AbnormalModel{ @@ -256,6 +267,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.ColorDev, Name: ALNORMAL_NAMES[NXU_VQD_ABN_COLORDEV], + Mode: "vqd_color", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -269,6 +281,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.LgtDark, Name: ALNORMAL_NAMES[NXU_VQD_ABN_LIGHT], + Mode: "vqd_lgt_light", }) } @@ -277,6 +290,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.LgtDark, Name: ALNORMAL_NAMES[NXU_VQD_ABN_DARK], + Mode: "vqd_lgt_dark", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -292,6 +306,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Clarity, Name: ALNORMAL_NAMES[NXU_VQD_ABN_CLARITY], + Mode: "vqd_clarity", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -305,6 +320,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Noise, Name: ALNORMAL_NAMES[NXU_VQD_ABN_NOISE], + Mode: "vqd_noise", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -318,6 +334,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Contrast, Name: ALNORMAL_NAMES[NXU_VQD_ABN_CONTRAST], + Mode: "vqd_contrast", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -333,6 +350,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Occlusion, Name: ALNORMAL_NAMES[NXU_VQD_ABN_OCCLUSION], + Mode: "vqd_occlusion", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -346,6 +364,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Blue, Name: ALNORMAL_NAMES[NXU_VQD_ABN_BLUE], + Mode: "vqd_blue", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -359,6 +378,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Shark, Name: ALNORMAL_NAMES[NXU_VQD_ABN_SHARK], + Mode: "vqd_shark", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -372,6 +392,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Freeze, Name: ALNORMAL_NAMES[NXU_VQD_ABN_FREEZE], + Mode: "vqd_freeze", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -385,6 +406,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Mosaic, Name: ALNORMAL_NAMES[NXU_VQD_ABN_MOSAIC], + Mode: "vqd_mosaic", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ @@ -398,6 +420,7 @@ func (v *VQDHandle) parseVQD(result VQDResult) (AbnormalModel, bool) { abnormals.Abnormals = append(abnormals.Abnormals, Abnormal{ Value: result.Flower, Name: ALNORMAL_NAMES[NXU_VQD_ABN_FLOWER], + Mode: "vqd_flower", }) } abnormals.DefaultValues = append(abnormals.DefaultValues, DefaultValue{ diff --git a/web/src/components/AddVqdTask.tsx b/web/src/components/AddVqdTask.tsx index f079d98..98a13de 100644 --- a/web/src/components/AddVqdTask.tsx +++ b/web/src/components/AddVqdTask.tsx @@ -189,7 +189,7 @@ const AddVqdTask = forwardRef( }}>选择通道 - + - + { - console.log("类型", v); - + setPagination((prev) => ({ + ...prev, + mode: v, + })); } } options={arrList.map((item: any) => { return { - label: item.name, - value: item.id, + label: item.label, + value: item.value, }; })} optionRender={(option) => ( @@ -255,7 +271,7 @@ export default function VqdAlarmPage() { )} - /> */} + /> -
- 任务名称:{item.task_name} +
+ 通道名称: {item.channel_name}({item.channel_id})
+
+ 检出时间: {item.created_at} +
+ {/* 通道:{item.channel_name || item.channel_id} */} -

{item.created_at}

+
+ 所属任务: {item.task_name} +
-
通道: {item.channel_name || item.channel_id}
-
诊断计划: {item.plan_name}
-
诊断模板: {item.task_template_name}
+
诊断时间: {item.plan_name}
+
诊断参数: {item.task_template_name}
)} title="详情">
diff --git a/web/src/components/VqdTask.tsx b/web/src/components/VqdTask.tsx index 7fd99df..9abce43 100644 --- a/web/src/components/VqdTask.tsx +++ b/web/src/components/VqdTask.tsx @@ -109,7 +109,7 @@ export default function VqdTaskPage() { // 表格列定义 const columns: ColumnsType = [ { - title: "名称", + title: "诊断任务", dataIndex: "name", align: "center", }, @@ -124,7 +124,7 @@ export default function VqdTaskPage() { ), }, { - title: "诊断模板", + title: "诊断参数", dataIndex: "task_template_name", align: "center", render: (text, record) => ( @@ -134,7 +134,7 @@ export default function VqdTaskPage() { ), }, { - title: "任务计划", + title: "诊断时间", dataIndex: "time_template_name", align: "center", render: (text, record) => ( diff --git a/web/src/components/VqdTimeTemplate.tsx b/web/src/components/VqdTimeTemplate.tsx index f03751f..16a9cb1 100644 --- a/web/src/components/VqdTimeTemplate.tsx +++ b/web/src/components/VqdTimeTemplate.tsx @@ -179,7 +179,7 @@ export default function VqdTimeTemplatePage() { {/* refetch()} />
diff --git a/web/src/components/channel/Channel.tsx b/web/src/components/channel/Channel.tsx index 592837b..85fbd31 100644 --- a/web/src/components/channel/Channel.tsx +++ b/web/src/components/channel/Channel.tsx @@ -119,7 +119,7 @@ const ChannelModel: React.FC = forwardRef(({onCallback},ref) => { const onCancel = () => { setOpen(false); if (selectedRowKeys.length>0) { - onCallback(selectedRows[0].id, selectedRows[0].name||selectedRows[0].id) + onCallback(selectedRows[0].id, selectedRows[0].name) } setSelectedRowKeys([]) }; diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx index 1277561..d59bfb3 100644 --- a/web/src/pages/Home.tsx +++ b/web/src/pages/Home.tsx @@ -21,7 +21,7 @@ export default function Home() { const items: MenuItem[] = [ { key: "sub0", - label: "设备视频诊断", + label: "视频诊断任务", icon: , }, { @@ -31,12 +31,12 @@ export default function Home() { }, { key: "sub2", - label: "诊断计划", + label: "诊断时间管理", icon: , }, { key: "sub3", - label: "诊断参数", + label: "诊断参数设置", icon: , }, { @@ -52,10 +52,9 @@ export default function Home() { return ( -
+ -
- + + {/* */} {currentMenu == "sub0" && ( diff --git a/web/src/types/vqdalarm.ts b/web/src/types/vqdalarm.ts index 4894ee0..c983214 100644 --- a/web/src/types/vqdalarm.ts +++ b/web/src/types/vqdalarm.ts @@ -56,6 +56,10 @@ export type VqdAlarmReq = { * 名称模糊搜索 */ name?: string; + /** + * 类型 + */ + mode?: string; /** * 页码(1~N) */