package com.cirle.scientific;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Calendar;

public class LiveServiceTest extends Test{

//    @Autowired
//    private QkjLiveDao qkjLiveDao;
//
//    @Autowired
//    private LiveService liveService;
//
//    @org.junit.Test
//    public void updateEndTime() throws InterruptedException {
//        QkjLive live = new QkjLive();
//        live.setId(1L);
//        live.setLiveEndTime(Calendar.getInstance());
//        qkjLiveDao.save(live);
//        System.out.println("没问题");
//    }
//
//    @org.junit.Test
//    public void autoIncNum() throws InterruptedException {
//
//        String a = "{\"times\":\"23:00-23:30,60_16:30-17:00,40\",\"lives\":\"201:8102\",\"switch\":\"on\"}";
//        String a2 = "{\"times\":\"23:00-23:30,60_16:30-17:00,40\",\"lives\":\"201:8102\",\"switch\":\"off\"}";
//        String a3 = "[{\"times\":\"23:00-23:30,60_16:30-17:00,40\",\"lives\":\"201:8102\",\"switch\":\"on\"},{\"times\":\"23:00-23:30,60_16:30-17:00,40\",\"lives\":\"201:8102\",\"switch\":\"on\"}]";
//
//        liveService.autoIncNum(a);
//        Thread.sleep(30000);
//        liveService.autoIncNum(a2);
//        System.out.println("没问题");
//    }
//
//    @org.junit.Test
//    public void autoIncNum2() throws InterruptedException {
//
//        String a2 = "{\"times\":\"23:00-23:30,60_16:30-17:00,40\",\"lives\":\"201:8102\",\"switch\":\"off\"}";
//        liveService.autoIncNum(a2);
//        System.out.println("没问题");
//    }
//
//    public static void main(String[] args) {
//        JSONObject json = new JSONObject();//new一个json对象
//        json.put("times","23:00-23:30,60_16:30-17:00,40");
//        json.put("lives","201:8102");
//        json.put("switch", "off");
//
//
//        //String tojsonstring=json.toJSONString();//将json格式的数据转换为字符格式、
//        String tojsonstring="[{\"times\":\"23:00-23:30,60_16:30-17:00,40\",\"lives\":\"201:8102\",\"switch\":\"on\"},{\"times\":\"23:00-23:30,60_16:30-17:00,40\",\"lives\":\"201:8102\",\"switch\":\"on\"}]";
//        try {
//            tojsonstring= URLEncoder.encode(tojsonstring,"utf-8");//将数据进行编码
//        } catch (UnsupportedEncodingException e) {
//            throw new RuntimeException(e);
//        }
//        System.out.println("asdfasd="+ tojsonstring);
//    }
//
//    public static long getnum(long incr){
//
//
//
//        int random =    (int) ((Math.random() *10+1) +incr) ;
//        if(random<0){
//            random=0;
//        }
//        int MAX = 10000;
//        if(random>MAX ){
//            random = random%MAX;
//        }
//        return random;
//
//    }
}
