mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-05-07 04:21:25 +08:00
[feat]添加规则引擎debug功能
This commit is contained in:
@@ -11,7 +11,7 @@ type (
|
||||
DeviceAlarmModel interface {
|
||||
Insert(data entity.DeviceAlarm) error
|
||||
FindOne(id string) *entity.DeviceAlarm
|
||||
FindOneByType(deviceId, ty, state string) *entity.DeviceAlarm
|
||||
FindOneByType(deviceId, ty, state string) (*entity.DeviceAlarm, error)
|
||||
FindListPage(page, pageSize int, data entity.DeviceAlarmForm) (*[]entity.DeviceAlarm, int64)
|
||||
Update(data entity.DeviceAlarm) error
|
||||
Delete(ids []string)
|
||||
@@ -41,12 +41,14 @@ func (m *alarmModelImpl) FindOne(id string) *entity.DeviceAlarm {
|
||||
return resData
|
||||
}
|
||||
|
||||
func (m *alarmModelImpl) FindOneByType(deviceId, ty, state string) *entity.DeviceAlarm {
|
||||
func (m *alarmModelImpl) FindOneByType(deviceId, ty, state string) (*entity.DeviceAlarm, error) {
|
||||
resData := new(entity.DeviceAlarm)
|
||||
db := global.Db.Table(m.table).Where("device_id = ?", deviceId).Where("type = ? ", ty).Where("state = ? ", state)
|
||||
err := db.First(resData).Error
|
||||
biz.ErrIsNil(err, "查询设备告警失败")
|
||||
return resData
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resData, nil
|
||||
}
|
||||
|
||||
func (m *alarmModelImpl) FindListPage(page, pageSize int, data entity.DeviceAlarmForm) (*[]entity.DeviceAlarm, int64) {
|
||||
|
||||
@@ -28,7 +28,7 @@ func BuildRunDeviceRpc(deviceId, mode string, metadata map[string]interface{}) e
|
||||
dataCode := ruleData.LfData.DataCode
|
||||
code, _ := json.Marshal(dataCode)
|
||||
//新建规则链实体
|
||||
instance, errs := rule_engine.NewRuleChainInstance(code)
|
||||
instance, errs := rule_engine.NewRuleChainInstance(findOne.Id, code)
|
||||
if len(errs) > 0 {
|
||||
return errs[0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user