计算量增加调试机制
This commit is contained in:
parent
14d49d08bf
commit
2c453abad1
@ -82,7 +82,6 @@ public class FunctionSaveCalcData extends AbstractVariadicFunction {
|
|||||||
dt.setIotModelField(attr);
|
dt.setIotModelField(attr);
|
||||||
dataList.add(dt);
|
dataList.add(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataService.updateCalFieldData(dataList);
|
dataService.updateCalFieldData(dataList);
|
||||||
return AviatorRuntimeJavaType.valueOf(0);
|
return AviatorRuntimeJavaType.valueOf(0);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.das.modules.calc.service;
|
package com.das.modules.calc.service;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.das.modules.cache.service.CacheService;
|
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;
|
||||||
@ -28,9 +29,19 @@ public class CalcJob implements Job {
|
|||||||
AviatorEvaluatorInstance instance = (AviatorEvaluatorInstance) dataMap.get("aviator");
|
AviatorEvaluatorInstance instance = (AviatorEvaluatorInstance) dataMap.get("aviator");
|
||||||
CalcModule calcModule = (CalcModule) dataMap.get("module");
|
CalcModule calcModule = (CalcModule) dataMap.get("module");
|
||||||
CacheService cacheService = (CacheService) dataMap.get("cache");
|
CacheService cacheService = (CacheService) dataMap.get("cache");
|
||||||
|
Boolean isDebug = (Boolean) dataMap.get("isDebug");
|
||||||
|
String debugTaskName = (String) dataMap.get("debugTaskName");
|
||||||
if (instance == null || calcModule == null || cacheService == null) {
|
if (instance == null || calcModule == null || cacheService == null) {
|
||||||
throw new JobExecutionException("calcModule is null");
|
throw new JobExecutionException("calcModule is null");
|
||||||
}
|
}
|
||||||
|
if (isDebug){
|
||||||
|
if (StrUtil.isBlank(debugTaskName)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!debugTaskName.equals(calcModule.getName())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
Expression expression = instance.getCachedExpressionByKey(calcModule.getName());
|
Expression expression = instance.getCachedExpressionByKey(calcModule.getName());
|
||||||
if (expression == null) {
|
if (expression == null) {
|
||||||
log.error("expression is null, calcModule={}", calcModule.getName());
|
log.error("expression is null, calcModule={}", calcModule.getName());
|
||||||
@ -38,6 +49,8 @@ public class CalcJob implements Job {
|
|||||||
}
|
}
|
||||||
//准备全局变量
|
//准备全局变量
|
||||||
Map<String,Object> envs = expression.newEnv();
|
Map<String,Object> envs = expression.newEnv();
|
||||||
|
//调试变量
|
||||||
|
envs.put("ISDEBUG", isDebug);
|
||||||
//脚本名称
|
//脚本名称
|
||||||
envs.put("G_SCRIPTNAME", calcModule.getName());
|
envs.put("G_SCRIPTNAME", calcModule.getName());
|
||||||
//风场信息
|
//风场信息
|
||||||
|
@ -18,6 +18,7 @@ import jakarta.annotation.PreDestroy;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.*;
|
import org.quartz.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -51,6 +52,12 @@ public class CalcService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
AdminRedisTemplate adminRedisTemplate;
|
AdminRedisTemplate adminRedisTemplate;
|
||||||
|
|
||||||
|
@Value("${calc.debug.enable}")
|
||||||
|
Boolean isDebug;
|
||||||
|
|
||||||
|
@Value("${calc.debug.task-name")
|
||||||
|
String debugTaskName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算引擎实例
|
* 计算引擎实例
|
||||||
*/
|
*/
|
||||||
@ -68,6 +75,8 @@ public class CalcService {
|
|||||||
dataMap.put("module", scriptModule);
|
dataMap.put("module", scriptModule);
|
||||||
dataMap.put("aviator", aviator);
|
dataMap.put("aviator", aviator);
|
||||||
dataMap.put("cache", cacheService);
|
dataMap.put("cache", cacheService);
|
||||||
|
dataMap.put("isDebug", isDebug);
|
||||||
|
dataMap.put("debugTaskName", debugTaskName);
|
||||||
JobKey jobKey = JobKey.jobKey(scriptModule.getName(), "CalcEngine");
|
JobKey jobKey = JobKey.jobKey(scriptModule.getName(), "CalcEngine");
|
||||||
if (sh.checkExists(jobKey)){
|
if (sh.checkExists(jobKey)){
|
||||||
throw new SchedulerException("计算模块已启动,请先停止该模块");
|
throw new SchedulerException("计算模块已启动,请先停止该模块");
|
||||||
|
@ -86,9 +86,15 @@ captcha:
|
|||||||
expire: 120
|
expire: 120
|
||||||
|
|
||||||
das:
|
das:
|
||||||
|
debug: true
|
||||||
aes:
|
aes:
|
||||||
key: b6967ee87b86d85a
|
key: b6967ee87b86d85a
|
||||||
|
|
||||||
|
calc:
|
||||||
|
debug:
|
||||||
|
enable: true
|
||||||
|
task-name:
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com:
|
com:
|
||||||
|
@ -85,7 +85,13 @@ captcha:
|
|||||||
verify-type: calculate
|
verify-type: calculate
|
||||||
expire: 120
|
expire: 120
|
||||||
|
|
||||||
|
calc:
|
||||||
|
debug:
|
||||||
|
enable: false
|
||||||
|
task-name:
|
||||||
|
|
||||||
das:
|
das:
|
||||||
|
debug: false
|
||||||
aes:
|
aes:
|
||||||
key: b6967ee87b86d85a
|
key: b6967ee87b86d85a
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user