package com.jiayue.ipfcst.console.service;

import java.io.IOException;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.alibaba.fastjson.JSON;
import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.AviatorEvaluatorInstance;
import com.googlecode.aviator.Expression;
import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;

/**
 * @author 修唯xiuwei
 * @version 3.0
 */
public class Test {
  public static void main(String[] args) throws IOException {
    String exprALL="P_.*?_P";
    Pattern expr= Pattern.compile("(?<=P_).*?(?=_P)");
    String str="let t=(now()%86400000)/3600000+8;if(t>0&&t<3){return 0;}else{return P_1_P;}";
    Matcher matcher = expr.matcher(str);
    Map<String,Object> map=new HashMap<>();
  /*  while(matcher.find()){
      String s=matcher.group();
      map.put("P_"+s+"_P",s.length());
    }*/
  map.put("P_1_P",20);
    Expression compiledExp = AviatorEvaluator.compile(str);
    Object re = compiledExp.execute(map);
    System.out.println(re);
    DateTime date=DateTime.now();
    date=date.dayOfWeek().roundFloorCopy();
    System.out.println(System.currentTimeMillis()%86400000);
    System.out.println(new DateTime().getMillis());
   // System.out.println(new DateTime().withMillis((Long)re).toString("yyyy-MM-dd HH:mm:ss"));
  }
}
