Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
a7fef75378
@ -5,6 +5,7 @@ import com.das.modules.cache.service.CacheService;
|
|||||||
import com.das.modules.calc.domain.entity.CalcModule;
|
import com.das.modules.calc.domain.entity.CalcModule;
|
||||||
import com.googlecode.aviator.AviatorEvaluatorInstance;
|
import com.googlecode.aviator.AviatorEvaluatorInstance;
|
||||||
import com.googlecode.aviator.Expression;
|
import com.googlecode.aviator.Expression;
|
||||||
|
import com.googlecode.aviator.runtime.type.AviatorRuntimeJavaType;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobDataMap;
|
import org.quartz.JobDataMap;
|
||||||
@ -13,6 +14,7 @@ import org.quartz.JobExecutionException;
|
|||||||
import org.springframework.util.StopWatch;
|
import org.springframework.util.StopWatch;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CalcJob implements Job {
|
public class CalcJob implements Job {
|
||||||
@ -34,7 +36,12 @@ public class CalcJob implements Job {
|
|||||||
log.error("expression is null, calcModule={}", calcModule.getName());
|
log.error("expression is null, calcModule={}", calcModule.getName());
|
||||||
throw new JobExecutionException("expression is null");
|
throw new JobExecutionException("expression is null");
|
||||||
}
|
}
|
||||||
Map<String,Object> envs = expression.newEnv("G_DEVICES", cacheService.getEquipmentCache().getDevicesCache());
|
//准备全局变量
|
||||||
|
Map<String,Object> envs = expression.newEnv();
|
||||||
|
//风场信息
|
||||||
|
envs.put("G_WF", cacheService.getEquipmentCache().getDevicesCache().stream().filter(c->c.getObjectType().equals(10001)).findFirst().get());
|
||||||
|
//风机信息
|
||||||
|
envs.put("G_GENS", cacheService.getEquipmentCache().getDevicesCache().stream().filter(c->c.getObjectType().equals(10002)).collect(Collectors.toList()));
|
||||||
Object result = expression.execute(envs);
|
Object result = expression.execute(envs);
|
||||||
sw.stop();
|
sw.stop();
|
||||||
log.debug("任务[{}]已执行,结果:{}, 耗时:{}秒", calcModule.getName(), result, sw.getTotalTimeMillis()/1000.0);
|
log.debug("任务[{}]已执行,结果:{}, 耗时:{}秒", calcModule.getName(), result, sw.getTotalTimeMillis()/1000.0);
|
||||||
|
Loading…
Reference in New Issue
Block a user