修复计算量BUG

This commit is contained in:
谷成伟 2024-11-27 14:58:33 +08:00
parent 098b1cd341
commit 205f8e8cf6
2 changed files with 3 additions and 1 deletions

View File

@ -34,7 +34,7 @@ public class CalcJob implements Job {
log.error("expression is null, calcModule={}", calcModule.getName());
throw new JobExecutionException("expression is null");
}
Map<String,Object> envs = expression.newEnv("G_DEVICES", cacheService.getEquipmentCache().getDevicesCache());
Map<String,Object> envs = expression.newEnv("G_DEVICES", cacheService.getEquipmentCache().getDevicesCache(), "G_WINDFARM");
Object result = expression.execute(envs);
sw.stop();
log.debug("任务[{}]已执行,结果:{}, 耗时:{}秒", calcModule.getName(), result, sw.getTotalTimeMillis()/1000.0);

View File

@ -73,6 +73,7 @@ public class CalcService {
if (sh.checkExists(jobKey)){
throw new SchedulerException("计算模块已启动,请先停止该模块");
}
aviator.compile(scriptModule.getName(), scriptModule.getScript(), true);
JobDetail jobDetail = JobBuilder
.newJob(CalcJob.class)
.setJobData(dataMap)
@ -95,6 +96,7 @@ public class CalcService {
JobKey jobKey = JobKey.jobKey(name, "CalcEngine");
if (sh.checkExists(jobKey)){
sh.deleteJob(jobKey);
aviator.invalidateCacheByKey(name);
}
}