import com.ruoyi.common.utils.jep.JEPUtils;
import com.ruoyi.project.business.dto.JEPCustomFunction.*;
import org.junit.jupiter.api.Test;
import org.lsmp.djep.djep.DJep;
import org.lsmp.djep.groupJep.GroupJep;
import org.nfunk.jep.JEP;
import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.If;
import org.nfunk.jep.function.Sum;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class codeTest {

    @Test
    public void mikrdir() {
        String destinationDirPath = "\\\\172.28.184.25\\国内事业部\\Personal\\jubs";

        String sourceFilePath = "C:\\Users\\jubs\\Desktop\\微信图片_20240621090541.png";
        File file = new File(destinationDirPath + "\\1.txt");
        try {
            if (file.createNewFile()) {
                System.out.println("文件创建成功");
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }


    @Test
    public void test() throws ParseException {
        String s = "0.4015*100";
     JEP jep=new JEP();
     jep.parse(s);
     jep.parseExpression(s);
        System.out.println(jep.getValueAsObject());

        DJep jep2 = new DJep();

        System.out.println(jep2.getValueAsObject());




    }

    @Test
    public void test2() {
        String s = "ROUND(1.5)";
        String s2 = "ROUND(1.4)";
        String s3 = "ROUND(1.5,1)";
        String s4 = "ROUND(1.4,1)";
        String s5 = "ROUND(1.56,1)";
        String s6 = "ROUND(1.54,1)";
        String s7 = "ROUND(1.56,2)";


        JEP jep = new JEP();
        //加入目前支持的函数
        jep.addFunction("ROUND", new CustomRoundFunction());
        jep.parseExpression(s);
        System.out.println("ROUND(1.5)的结果是=========>" + jep.getValue());

        jep.parseExpression(s2);

        System.out.println("ROUND(1.4)的结果是=========>" + jep.getValue());

        jep.parseExpression(s3);

        System.out.println("ROUND(1.5,1)的结果是=========>" + jep.getValue());

        jep.parseExpression(s4);

        System.out.println("ROUND(1.4,1)的结果是=========>" + jep.getValue());

        jep.parseExpression(s5);

        System.out.println("ROUND(1.56,1)的结果是=========>" + jep.getValue());

        jep.parseExpression(s6);

        System.out.println("ROUND(1.54,1)的结果是=========>" + jep.getValue());

        jep.parseExpression(s7);

        System.out.println("ROUND(1.56,2)的结果是=========>" + jep.getValue());
    }
}
