package com.yihu.wlyy.task;

import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * 签约推送
 * <p>
 * Created by lyr-pc on 2016/9/26.
 */
public class SignUploadTask implements Runnable {

    private static Logger logger = LoggerFactory.getLogger(SignUploadTask.class);

    String code = "";

    public SignUploadTask(String code) {
        this.code = code;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(3000);
            String url = SystemConf.getInstance().getJwUrl();
            String resultStr = HttpUtil.sendPost(url + "/third/sign/UploadSignFamily?code=" + code, "");
            JSONObject json = new JSONObject(resultStr);

            if (json.getInt("status") == 200) {
                logger.info("sign-info-upload-success:" + code);
            } else {
                logger.error("sign-info-upload-failed:" + code);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
