|
@@ -3,9 +3,13 @@ package com.ruoyi.web.runner;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import com.alibaba.druid.pool.DruidDataSource;
|
|
import com.alibaba.druid.pool.DruidDataSource;
|
|
import com.ruoyi.framework.datasource.DynamicDataSource;
|
|
import com.ruoyi.framework.datasource.DynamicDataSource;
|
|
|
|
+import com.ruoyi.ucp.entity.Formula;
|
|
import com.ruoyi.ucp.entity.Method;
|
|
import com.ruoyi.ucp.entity.Method;
|
|
import com.ruoyi.ucp.entity.UcpDataSource;
|
|
import com.ruoyi.ucp.entity.UcpDataSource;
|
|
import com.ruoyi.ucp.feign.AdapterApi;
|
|
import com.ruoyi.ucp.feign.AdapterApi;
|
|
|
|
+import com.ruoyi.ucp.glue.GlueFactory;
|
|
|
|
+import com.ruoyi.ucp.handler.IJobHandler;
|
|
|
|
+import com.ruoyi.ucp.handler.impl.MyJobHandler;
|
|
import com.ruoyi.ucp.mapper.TurbineInfoMapper;
|
|
import com.ruoyi.ucp.mapper.TurbineInfoMapper;
|
|
import com.ruoyi.ucp.service.*;
|
|
import com.ruoyi.ucp.service.*;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
@@ -23,8 +27,8 @@ public class LoadDataSourceRunner implements CommandLineRunner {
|
|
@Resource
|
|
@Resource
|
|
private IUcpDataSourceService ucpDataSourceService;
|
|
private IUcpDataSourceService ucpDataSourceService;
|
|
|
|
|
|
- @Resource
|
|
|
|
- private ScriptEngine engine;
|
|
|
|
|
|
+ //@Resource
|
|
|
|
+ //private ScriptEngine engine;
|
|
@Resource
|
|
@Resource
|
|
private AdapterApi adapter;
|
|
private AdapterApi adapter;
|
|
@Resource
|
|
@Resource
|
|
@@ -37,6 +41,10 @@ public class LoadDataSourceRunner implements CommandLineRunner {
|
|
private IMethodService methodService;
|
|
private IMethodService methodService;
|
|
@Resource
|
|
@Resource
|
|
private ILineInfoDayService lineInfoDayService;
|
|
private ILineInfoDayService lineInfoDayService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IFormulaService formulaService;
|
|
|
|
+ @Resource
|
|
|
|
+ private MyJobHandler myJobHandler;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void run(String... args) {
|
|
public void run(String... args) {
|
|
@@ -44,18 +52,27 @@ public class LoadDataSourceRunner implements CommandLineRunner {
|
|
List<DruidDataSource> dataSources = BeanUtil.copyToList(list, DruidDataSource.class);
|
|
List<DruidDataSource> dataSources = BeanUtil.copyToList(list, DruidDataSource.class);
|
|
dynamicDataSource.createDataSource(dataSources);
|
|
dynamicDataSource.createDataSource(dataSources);
|
|
|
|
|
|
- engine.put("adapter", adapter);
|
|
|
|
- engine.put("pointService", pointService);
|
|
|
|
- engine.put("stationInfoDayService", stationInfoDayService);
|
|
|
|
- engine.put("stationInfoHourService", stationInfoHourService);
|
|
|
|
- engine.put("lineInfoDayService", lineInfoDayService);
|
|
|
|
|
|
+ //engine.put("adapter", adapter);
|
|
|
|
+ //engine.put("pointService", pointService);
|
|
|
|
+ //engine.put("stationInfoDayService", stationInfoDayService);
|
|
|
|
+ //engine.put("stationInfoHourService", stationInfoHourService);
|
|
|
|
+ //engine.put("lineInfoDayService", lineInfoDayService);
|
|
|
|
|
|
List<Method> methods = methodService.list();
|
|
List<Method> methods = methodService.list();
|
|
|
|
+ List<Formula> formulas = formulaService.list();
|
|
|
|
+ String functionCode = "";
|
|
try {
|
|
try {
|
|
for (Method method : methods) {
|
|
for (Method method : methods) {
|
|
- engine.eval(method.getMethodExpression());
|
|
|
|
|
|
+ //engine.eval(method.getMethodExpression());
|
|
|
|
+ functionCode = GlueFactory.getFunctionTemplate()
|
|
|
|
+ .replace("//此处加公式", method.getMethodExpression()+"\n//此处加公式");
|
|
|
|
+ }
|
|
|
|
+ for (Formula formula : formulas) {
|
|
|
|
+ functionCode = functionCode.replace("//此处加公式", formula.getFormulaExpression()+"\n//此处加公式");
|
|
}
|
|
}
|
|
- } catch (ScriptException e) {
|
|
|
|
|
|
+ IJobHandler jobHandler = GlueFactory.getInstance().loadNewInstance(functionCode);
|
|
|
|
+ myJobHandler.setJobHandler(jobHandler);
|
|
|
|
+ } catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|