package com.casic.missiles.modular.system.rs;


import com.casic.missiles.core.util.SpringContextHolder;
import com.casic.missiles.modular.system.dto.CommConfigDTO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by lenovo on 2018/1/9.
 */
public class TempHumiRequest extends AbstractRequest {

    private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    @Override
    public void send(String devCode, String content, String attemptsMax) {
        RedisCommon  redisCommon = SpringContextHolder.getBean("redisCommon");
        CommConfigDTO commConfigDTO = new CommConfigDTO();
        commConfigDTO.setInterval(Long.valueOf(content.split(",")[0]));
        commConfigDTO.setRepeat(Long.valueOf(content.split(",")[1]));
        commConfigDTO.setTimes(Long.valueOf(content.split(",")[2]));
        commConfigDTO.setAcqStart(content.split(",")[3].replace(":",""));
        if (StringUtils.isNotBlank(content.split(",", 6)[4])) {
            commConfigDTO.setIp(content.split(",", 6)[4]);
            commConfigDTO.setPort(Long.valueOf(content.split(",", 6)[5]));
        }
        redisCommon.setRedisConfig(devCode, commConfigDTO);
        if (/*"1".equals(this.getNetType()) &&*/ StringUtils.isNotBlank(getConcentratorCode()))
            redisCommon.setRedisConcentrator(getConcentratorCode(), devCode, attemptsMax);

    }

}
