调整告警检索

This commit is contained in:
Sake 2026-01-28 14:00:33 +08:00
parent a7690d7542
commit 45b4f526d7
16 changed files with 111 additions and 38 deletions

View File

@ -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

View File

@ -12,8 +12,8 @@ import (
// 通过修改版本号,来控制是否执行表迁移
var (
DBVersion = "0.0.20"
DBRemark = "增加同步记录表"
DBVersion = "0.0.21"
DBRemark = "添加告警查询字段"
)
// NewVersionCore ...

View File

@ -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

View File

@ -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"` // 设置的默认阈值
}

View File

@ -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())

View File

@ -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"` // 设置的默认阈值

View File

@ -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

View File

@ -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

View File

@ -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{

View File

@ -189,7 +189,7 @@ const AddVqdTask = forwardRef<AddVqdTaskRef, AddVqdTaskProps>(
}}></Button>
</Space.Compact>
</Form.Item>
<Form.Item name="task_template_id" label="关联模板" rules={[{ required: true, message: "请选择模板" }]}>
<Form.Item name="task_template_id" label="关联诊断参数" rules={[{ required: true, message: "请选择模板" }]}>
<Select
placeholder="请选择模板"
onChange={(res, item: any) => {
@ -204,7 +204,7 @@ const AddVqdTask = forwardRef<AddVqdTaskRef, AddVqdTaskProps>(
></Select>
</Form.Item>
<Form.Item name="time_template_id" label="关联计划" rules={[{ required: true, message: "请选择计划" }]}>
<Form.Item name="time_template_id" label="关联诊断时间" rules={[{ required: true, message: "请选择计划" }]}>
<Select
placeholder="请选择计划"
onChange={(res, item: any) => {

View File

@ -16,9 +16,23 @@ export default function VqdAlarmPage() {
const [pagination, setPagination] = useState({
page: 1,
size: 12,
name: ""
name: "",
mode: "",
});
const [arrList, setArrList] = useState<any>([{ name: "全部类型", id: 0 }]);
const [arrList, setArrList] = useState<any>([{ label: "全部类型", value: "" },
{ label: "过亮异常", value: "vqd_lgt_light" },
{ label: "过暗异常", value: "vqd_lgt_dark" },
{ label: "蓝屏异常", value: "vqd_blue" },
{ label: "清晰度异常", value: "vqd_clarity" },
{ label: "抖动异常", value: "vqd_shark" },
{ label: "冻结异常", value: "vqd_freeze" },
{ label: "偏色异常", value: "vqd_color" },
{ label: "遮挡异常", value: "vqd_occlusion" },
{ label: "噪声异常", value: "vqd_noise" },
{ label: "对比度异常", value: "vqd_contrast" },
{ label: "马赛克异常", value: "vqd_mosaic" },
{ label: "花屏异常", value: "vqd_flower" },
]);
const [templateData, setTemplateData] = useState<VqdAlarmItem[]>([]);
// 获取任务列表
const {
@ -233,19 +247,21 @@ export default function VqdAlarmPage() {
loading={moonLoading}
/> */}
<div className="w-[150px] ml-[20px]">
{/* <Select
defaultValue={0}
className="w-[100%] mr-2"
<Select
defaultValue={''}
className="w-32 mr-2"
placeholder="选择类型"
onChange={(v) => {
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() {
</span>
</Space>
)}
/> */}
/>
<Filter
searchLoading={isLoading}
@ -283,17 +299,22 @@ export default function VqdAlarmPage() {
})
}
</Flex>
<div>
<Space className="pt-2"> :{item.task_name}</Space>
<div className="pt-2 truncate" title={`${item.channel_name}(${item.channel_id})`}>
: {item.channel_name}({item.channel_id})
</div>
<div>
<Space className="pt-2">: {item.created_at}</Space>
</div>
{/* <Space className="pt-2"> 通道:{item.channel_name || item.channel_id}</Space> */}
<Flex justify="space-between" align="center">
<p className="m-0"> {item.created_at}</p>
<div>
<Space className="pt-2 pb-2">: {item.task_name}</Space>
</div>
<div>
<Popover content={(<>
<div>: {item.channel_name || item.channel_id}</div>
<div>: {item.plan_name}</div>
<div className="pb-2">: {item.task_template_name} </div>
<div>: {item.plan_name}</div>
<div className="pb-2">: {item.task_template_name} </div>
</>)} title="详情">
<Button type="text" icon={<InfoCircleOutlined />}></Button>
</Popover>

View File

@ -109,7 +109,7 @@ export default function VqdTaskPage() {
// 表格列定义
const columns: ColumnsType<VqdTaskItem> = [
{
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) => (

View File

@ -179,7 +179,7 @@ export default function VqdTimeTemplatePage() {
<Flex justify="space-between" align="center" className="mb-4">
<Space>
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
</Button>
{/* <Popconfirm
title="确定要批量删除文件吗?"
@ -226,7 +226,7 @@ export default function VqdTimeTemplatePage() {
{/* 编辑模态框 */}
<AddVqdTimeTemplate
ref={dialogRef}
title="添加/编辑模板"
title="添加/编辑时间模板"
onSuccess={() => refetch()}
/>
</div>

View File

@ -119,7 +119,7 @@ const ChannelModel: React.FC<IChannelModel> = 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([])
};

View File

@ -21,7 +21,7 @@ export default function Home() {
const items: MenuItem[] = [
{
key: "sub0",
label: "设备视频诊断",
label: "视频诊断任务",
icon: <FileSearchOutlined />,
},
{
@ -31,12 +31,12 @@ export default function Home() {
},
{
key: "sub2",
label: "诊断计划",
label: "诊断时间管理",
icon: <CarryOutOutlined />,
},
{
key: "sub3",
label: "诊断参数",
label: "诊断参数设置",
icon: <FileProtectOutlined />,
},
{
@ -52,10 +52,9 @@ export default function Home() {
return (
<Row gutter={16}>
<div>
<Col sm={24} md={24} lg={3} xl={3} xxl={3} className="w-full">
<Affix className="hidden lg:block" offsetTop={0}>
<Box
style={{ minWidth: "10rem", width: "12rem" }}
className="mr-0 px-0"
>
<Menu
@ -68,7 +67,6 @@ export default function Home() {
</Box>
</Affix>
<Box
style={{ minWidth: "10rem", width: "12rem" }}
className="mr-0 px-0 block lg:hidden"
>
<Menu
@ -79,8 +77,8 @@ export default function Home() {
items={items}
/>
</Box>
</div>
<Col sm={24} md={24} lg={18} xl={18} xxl={18} className="w-full">
</Col>
<Col sm={24} md={24} lg={21} xl={21} xxl={21} className="w-full">
{/* <Col sm={24} md={24} className="w-full"> */}
{currentMenu == "sub0" && (
<Box>

View File

@ -56,6 +56,10 @@ export type VqdAlarmReq = {
*
*/
name?: string;
/**
*
*/
mode?: string;
/**
* (1~N)
*/