package com.huatek.busi.dao;

import com.huatek.busi.entity.BusiCableCirculationCache;
import com.huatek.busi.entity.EquipmentTemperatureCache;
import com.huatek.busi.entity.IBusiCable;
import com.huatek.busi.service.transformer.EquipmentTemperatureCacheService;
import com.huatek.torch.sql.dao.impl.BaseDao;
import com.huatek.torch.util.uuid.Uuid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

/**
 * 电缆环流 Dao
 *
 * @author Bobi_huo
 * @date 2020-09-10 14:59
 */
@Repository
public class EquipmentTemperatureCacheDao extends BaseDao<EquipmentTemperatureCache, String> {
    @Autowired
    EquipmentTemperatureCacheService equipmentTemperatureCacheService;
    public int saveOrUpdate(EquipmentTemperatureCache equipmentTemperatureCache) {
        EquipmentTemperatureCache findSensorCode = equipmentTemperatureCacheService.findSensorCode(equipmentTemperatureCache.getSensorId());
        if (findSensorCode!=null){
            if (equipmentTemperatureCache.getSensorId().equals(findSensorCode.getSensorId())) {
                return equipmentTemperatureCacheService.updateSenSor(equipmentTemperatureCache);
            }
        }
        if (findSensorCode==null){
            equipmentTemperatureCache.setId(Uuid.getUUID());
            return this.add(equipmentTemperatureCache);
        }
        return equipmentTemperatureCacheService.updateSenSor(equipmentTemperatureCache);
    }
}
