package com.huatek.busi.dao;

import com.alibaba.fastjson.JSONObject;
import com.huatek.busi.dto.PushAlarmsDto;
import com.huatek.busi.vo.ResponseVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import com.huatek.busi.entity.BusiEqmWarning;
import com.huatek.torch.sql.dao.impl.BaseDao;
import com.huatek.torch.util.uuid.Uuid;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.Map;

/**
 * 设备预警表 Dao
 *
 * @author anker_cheng
 * @date Jun 26, 2019 3:31:49 PM
 */
@Slf4j
@Repository
public class  BusiEqmWarningDao extends BaseDao<BusiEqmWarning, String> {


    public int saveOrUpdate(BusiEqmWarning entity) {
        if(StringUtils.isEmpty(entity.getId())) {
            entity.setId(Uuid.getUUID());
            int add = this.add(entity);
            PushAlarmsDto dto = new PushAlarmsDto();
            dto.setWarningId(entity.getId());
            dto.setWarningMsg(entity.getWarningMsg());
            dto.setEqType(entity.getEqType());
            dto.setGzType(entity.getGzType());
            dto.setMainTreeId(entity.getMainTreeId());
            dto.setSiteId(entity.getSiteId());
            dto.setSensorCode(entity.getSensorId());
            return add;
        }
        return this.updateLocal(entity);
    }
}

