//package com.sundata.internalevaluation.calc.custom; // //import cn.hutool.core.util.RandomUtil; //import com.sundata.internalevaluation.script.ScriptUtil; //import com.sundata.internalevaluation.script.TemplateUtil; // //import java.text.SimpleDateFormat; //import java.util.*; // ///** // * Created by IntelliJ IDEA. // * // * @author JoeLazy // * @date 2025-02-14 17:12:49 // * @description: 测试Java方法获取参数 // */ //public class GetDataTest { // // private static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; // private static final String YYYYMMDD = "yyyyMMdd"; // private static final String HHMMSS = "HHmmss"; // private static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; // private static final String YYYY_MM_DD = "yyyy-MM-dd"; // private static final String HH_MM_SS = "HH:mm:ss"; // // public String getDateTimeNumber() { // return getStr(YYYYMMDDHHMMSS); // } // public String getDateNumber() { // return getStr(YYYYMMDD); // } // public String getTimeNumber() { // return getStr(HHMMSS); // } // public String getDateTime() { // return getStr(YYYY_MM_DD_HH_MM_SS); // } // public String getDate() { // return getStr(YYYY_MM_DD); // } // public String getTime() { // return getStr(HH_MM_SS); // } // // public String getStr(String format) { // SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); // return simpleDateFormat.format(nowDate()); // } // // public Date nowDate() { // return new Date(); // } // // // public int getInt(int i) { // return i; // } // // // public String getString(String str) { // return str; // } // // //// public void aa() { //// // 模板字符${value}的正则表达式 //// String regex = "\\$\\{([^}]+)}"; //// // 生成正则表达式对象 //// Pattern pattern = Pattern.compile(regex); //// //// // 应入参数 //// String[] values = {"workDate","account","orgcode","TaskId","TaskSerialNum"}; //// // 替换模板字符用 //// Map inputMap = new HashMap(); //// // 造假参数 //// inputMap.put("workDate","'a'"); //// inputMap.put("account","'a'"); //// inputMap.put("orgcode","'a'"); //// inputMap.put("TaskId","'a'"); //// inputMap.put("TaskSerialNum","'a'"); //// // 使用apache的StrSubstitutor替换模板字符 //// StrSubstitutor sub = new StrSubstitutor(inputMap); //// //// //// // 对请求中的数据逻辑说明的sql进行正则匹配 //// Matcher matcher = pattern.matcher(relationModel.getSqlCode()); //// // 判断缺失参数用 //// ArrayList paramList = new ArrayList(Arrays.asList(values)); //// // 游标 //// int matcherCount = 0; //// // 检查开始 //// while (matcher.find()) { //// if (!paramList.contains(matcher.group(1))) { //// String err = "数据初始化逻辑中,该参数[" + matcher.group(1) + "]不应存在!"; //// log.error(err); //// throw new BusinessException(err); //// } else { //// // 排除不缺失参数 //// paramList.remove(matcher.group(1)); //// } //// matcherCount++; //// } //// //// // 假参数赋值 //// String resolvedString = sub.replace(relationModel.getSqlCode()); //// } // // // // public static void main(String[] args) { //// String sql = "select * from a where a = ${a} and b = ${b} and c =${a}"; //// Map map = new HashMap<>(); //// //// map.put("a", "isA"); //// map.put("b", "isB"); // //// Map map = new HashMap<>(); //// map.put("isStaff", 0); //// map.put("isEmployrecord", 0); //// map.put("isBankBlack", 1); //// map.put("isIntro", 0); //// map.put("isCredit", false); //// map.put("str", "qiao"); //// String script = "${isStaff}==1 || ${isEmployrecord}==1 || ${isBankBlack}==1 || ${isIntro} ==1"; //// script = "isCredit==true"; //// script = "'${str}'=='qiao'"; //// script = TemplateUtil.execute(UUID.randomUUID().toString(), script, map); //// Object o = ScriptUtil.executeScript(UUID.randomUUID().toString(), script, map); // // // // // 创建绑定变量 // Map binding = new HashMap<>(); // // // 创建自定义对象 // binding.put("aNumber", 100); // binding.put("name", "CodeLife Leno"); // binding.put("location", "china Guangzhou"); // // // String scriptStr = """ // "Hello, $name from $location!" // """; // System.out.println(ScriptUtil.executeScript(UUID.randomUUID().toString(), scriptStr, binding)); // // System.out.println(""); // // test(); // //// bb(sql, map); // } // // // static void test() { // String scriptId = RandomUtil.randomString(10); // String scriptStr = """ // "Hello, $name from $location!" // """; // String scriptId2 = RandomUtil.randomString(10); // String scriptStr2 = """ // aNumber > 100 // """; // String templateId = RandomUtil.randomString(10); // String templateStr = """ // Hello, ${user.name}! // You have ${messages.size()} new messages. // <%// 使用 Groovy 脚本计算未读消息数 --%> // <% def unreadMessages = messages.count { it.startsWith("Unread") } %> // Unread messages000: ${unreadMessages} // <%// 条件判断 --%> // <% if (unreadMessages > 0) { %> // You have some unread messages. // <% } else { %> // All messages are read. // <% } %> // Messages: // <%// 遍历消息列表 --%> // ${messages.each { msg -> println(" -- " + msg) }} // """; // // // 创建绑定变量 // Map binding = new HashMap<>(); // // // 创建自定义对象 // User user = new User("Alice"); // binding.put("aNumber", 100); // binding.put("name", "CodeLife Leno"); // binding.put("location", "china Guangzhou"); // binding.put("user", user); // // 创建消息列表 // List messages = List.of("Unread Message 1", "Read Message 2", "Unread Message 3"); // binding.put("messages", messages); // // System.out.println(ScriptUtil.executeScript(scriptId, scriptStr, binding)); // System.out.println("--------------------------------------------"); // System.out.println(ScriptUtil.executeScript(scriptId2, scriptStr2, binding)); // System.out.println("--------------------------------------------"); // // templateStr = """ // <% if (approveSts == 03) { %>审批状态:审核中,<% } else { %>其他...,<% } %><% if (agrSts == 01) { %>额度状态:生效,<% } else if (agrSts == 02){ %>额度状态:手动冻结,<% } else if (agrSts == 02){%>额度状态:系统冻结,<% } %> // """; // // binding.put("approveSts",3); // binding.put("agrSts",1); // // System.out.println(TemplateUtil.execute(templateId, templateStr, binding)); // } // // // // 自定义 User 类 // static class User { // private String name; // // public User(String name) { // this.name = name; // } // // public String getName() { // return name; // } // } // //}