package com.duowenlvshi.duowenlszp;

import com.duowenlvshi.duowenlszp.app.alPay.alPay;
import com.duowenlvshi.duowenlszp.app.util.DeletEmoji;


import com.duowenlvshi.duowenlszp.app.util.UUIDUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;


/**
 * @author yang fang yu
 * @since 2019/8/20 10:11
 */
@Service
public class Test1 {
    @Autowired
    StringRedisTemplate redisTemplate;
    @Autowired
    DeletEmoji deletEmoji;
    @Autowired
    alPay alPay;


    @Test
    public void test(){
        String start = "2018-7" ;
        String end   = "至今";
        double startDate=0;
        double endDate=0;
        SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM");
        try {
            startDate = formatter.parse(start).getTime();
            if("至今".equals(end)){
                endDate =(double) System.currentTimeMillis();
            }else{
                endDate =(double) formatter.parse(end).getTime();
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Double year = ((endDate - startDate)/(1000 * 60 * 60 * 24 * 365l));
        Double yearc =Math.ceil(year);
    }
    @Test
    public void test2(){
        String ss ="\uD83D\uDE0B\uD83D\uDE00\uD83D\uDE01\uD83D\uDE02\uD83E\uDD23\uD83D\uDE03\uD83D\uDE04\uD83D\uDE05\uD83D\uDE06\uD83D\uDE09\uD83D\uDE0A\uD83D\uDE0B\uD83D\uDE0E\uD83D\uDE0D\uD83D\uDE18\uD83D\uDE17\uD83D\uDE19\uD83D\uDE1A☺️\uD83D\uDE42\uD83E\uDD17\uD83E\uDD29\uD83E\uDD14\uD83E\uDD28666";
        ss = deletEmoji.filterEmoji(ss,"");
        System.err.println(ss);
    }
    @Test
    public void test3(){
        Date d=new Date();
        SimpleDateFormat format=new SimpleDateFormat("yyyyMMddHHmmss");
        String s = format.format(d);
        System.out.println(s);
    }
    @Test
    public void test4(){
        String s = "20141030133525";
        String s1 = "2015-04-27 15:45:57";
        Date date = null;
        Date date2 = null;
        try {
            date = new SimpleDateFormat("yyyyMMddHHmmss").parse(s);
            date2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(s1);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("1"+date);
        System.out.println("2"+date2);

    }
    @Test
    public void test5(){
        Map map = new HashMap();
        map.put("1",1);
        map.put("2",2);
        System.out.println(map);
        map.remove("1");
        System.out.println(map);
    }
    @Test
    public void test6(){
        String str = UUID.randomUUID().toString();
        String temp = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24);
        String temp2 = str.replace("-","");
        System.out.println(str);
        System.out.println(temp);
        System.out.println(temp2);
    }
    @Test
    public void test7(){
        int i=0;
        while(i<100){
            int x=(int)((Math.random()*9+1)*100000);
            System.out.println(x);
            ++i;
        }
    }
    @Test
    public void test8(){
        List<Map> list = new ArrayList<>();
        Map map   = new HashMap();
        Map map2   = new HashMap();
        map.put("666","666");
        map2.put("777","777");
        list.add(map);
        list.add(map2);
        Iterator<Map> iterator = list.iterator();
        System.out.println(list);
        while (iterator.hasNext()) {
            Map map3 = iterator.next();
            if ("777".equals(map3.get("777"))) {
                iterator.remove();//使用迭代器的删除方法删除
            }
        }
        System.out.println(list);
    }
    @Test
    public void test9(){
        String intro = "expertise1,expertise2,expertise3";
        String newStrFirst = intro.replaceAll(",","|");
        System.err.println(newStrFirst);
    }
    @Test
    public void test10(){
        boolean b =redisTemplate.hasKey("pushAll");
        System.err.println(b);

        //String str3 = redisTemplate.opsForValue().get("");
        //redisTemplate.opsForValue().set(strArray1[0],strArray1[1]);
    }
    @Test
    public void test11(){
        String s = UUIDUtil.GetUUID();
        System.out.println(s);
    }
    @Test
    public void test12(){
        System.out.println(System.currentTimeMillis());

    }

}
