Search in sources :

Example 1 with DbMonitorNotifyLogService

use of io.jpom.service.dblog.DbMonitorNotifyLogService in project Jpom by dromara.

the class LoadJsonConfigToDb method convertMonitorLogField.

/**
 * 将 监控报警记录 里面但 logId 字段更新为 id
 */
public void convertMonitorLogField() {
    DbMonitorNotifyLogService monitorNotifyLogService = SpringUtil.getBean(DbMonitorNotifyLogService.class);
    String tableName = monitorNotifyLogService.getTableName();
    List<Entity> query = monitorNotifyLogService.query("select * from " + tableName + " order by createTime asc limit 1");
    Entity first = CollUtil.getFirst(query);
    if (first == null) {
        this.checkLogFiled(monitorNotifyLogService);
        return;
    }
    Object logId = first.get("logId");
    if (logId == null) {
        this.checkLogFiled(monitorNotifyLogService);
        return;
    }
    String sql = "update " + tableName + " set ID = LOGID where ID = '' and LOGID is not null  and LOGID <> '';";
    int execute = monitorNotifyLogService.execute(sql);
    if (execute > 0) {
        Console.log("convert monitor log field {}", execute);
    }
    // 标记包含旧字段
    MonitorNotifyLog.HAS_LOG_ID = true;
}
Also used : Entity(cn.hutool.db.Entity) JSONObject(com.alibaba.fastjson.JSONObject) DbMonitorNotifyLogService(io.jpom.service.dblog.DbMonitorNotifyLogService)

Aggregations

Entity (cn.hutool.db.Entity)1 JSONObject (com.alibaba.fastjson.JSONObject)1 DbMonitorNotifyLogService (io.jpom.service.dblog.DbMonitorNotifyLogService)1