diff --git a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java index 580c718c..c4d69b2d 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java @@ -6,8 +6,6 @@ import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService; import com.hzya.frame.util.GroovyUtil; import com.hzya.frame.web.entity.BaseResult; import com.hzya.frame.web.entity.JsonResultEntity; -import groovy.lang.GroovyClassLoader; -import groovy.lang.GroovyObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -24,28 +22,41 @@ import org.springframework.stereotype.Service; public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService { private static final Logger logger = LoggerFactory.getLogger(GroovyIntegrationServiceImpl.class); -// public static void main(String[] args) { -// HelloWorld helloWorld = new HelloWorld(); -// System.out.println(helloWorld.sayHello()); -// } - - public static void main(String[] args) throws IllegalAccessException, InstantiationException { - GroovyClassLoader groovyClassLoader = new GroovyClassLoader(); - - // 动态编译和加载Groovy脚本 - Class groovyClass = groovyClassLoader.parseClass("println(\"1231231\")"); - - // 创建Groovy类的实例 - GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance(); - // 执行Groovy脚本 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("name", "张三"); - Object returnObj = groovyObject.invokeMethod("run", jsonObject.toJSONString()); - } @Override public JsonResultEntity groovyScriptExecution(JSONObject jsonObject) { Object object = GroovyUtil.execute(jsonObject); return BaseResult.getSuccessMessageEntity(object); } + + public static void main(String[] args) { + java.lang.String str = "{\"project_org\":\"\",\"modify_time\":\"2024-06-17 16:52:34\",\"project_duty_dept\":null,\"project_name\":\"凯伍德组织档案\",\"document_rule_num\":1,\"add_status\":\"0\",\"delete_status\":\"1\",\"project_dutier\":\"\",\"id\":\"fb12734c8267488b96833633e68a7abc\",\"data_status\":\"F\",\"modify_user_id\":\"c796fd9ba4c9f5ff3cc2fa41a040e443\",\"sorts\":1,\"project_memo\":\"\",\"document_rule\":\"XM-2024-06-17-00001\",\"create_user_id\":\"c796fd9ba4c9f5ff3cc2fa41a040e443\",\"create_time\":\"2024-06-17 16:42:18\",\"company_id\":null,\"project_sh_name\":\"\",\"project_code\":\"01004\",\"project_currtype\":\"\",\"update_status\":\"0\",\"sts\":\"Y\",\"org_id\":\"0\",\"project_parentpro\":\"\",\"project_bill_type\":\"\"}"; + + A88772 s = new A88772(); + s .execute(str); + } + static class A88772 { + String execute(String jsonStr) { + com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr); + com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject(); + com.alibaba.fastjson.JSONObject ufinterfaceObject = new com.alibaba.fastjson.JSONObject(); + ufinterfaceObject.put("billtype", "supplier"); ufinterfaceObject.put("isexchange", "Y"); + ufinterfaceObject.put("replace", "Y"); ufinterfaceObject.put("sender", "OA"); + ufinterfaceObject.put("account", "01"); ufinterfaceObject.put("groupcode", "00"); + com.alibaba.fastjson.JSONObject billObject = new com.alibaba.fastjson.JSONObject(); + com.alibaba.fastjson.JSONObject billheadObject = new com.alibaba.fastjson.JSONObject(); + billheadObject.put("code", reqData.get("project_code")); billheadObject.put("supprop", "0"); + billheadObject.put("custstate", "1"); billheadObject.put("pk_supplierclass", "S01"); + billheadObject.put("pk_country", "CN"); billheadObject.put("pk_timezone", "P0800"); + billheadObject.put("pk_format", "ZH-CN"); billheadObject.put("enablestate", "2"); + billheadObject.put("name", reqData.get("project_sh_name")); billheadObject.put("pk_group", "00"); + billheadObject.put("pk_org", "003"); billheadObject.put("taxpayerid", "087981489021135119"); + returnObject.put("ufinterface",ufinterfaceObject); billObject.put("billhead", billheadObject); returnObject.put("bill",billObject); + System.out.println( returnObject.toJSONString()); + return returnObject.toJSONString(); + } + } + + + }