Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
ef2bc8cf55
@ -1,11 +1,6 @@
|
|||||||
package com.das.modules.calc.functions;
|
package com.das.modules.calc.functions;
|
||||||
|
|
||||||
import com.das.common.utils.AdminRedisTemplate;
|
import com.das.common.utils.AdminRedisTemplate;
|
||||||
import com.das.modules.cache.domain.DeviceInfoCache;
|
|
||||||
import com.das.modules.cache.service.CacheService;
|
|
||||||
import com.das.modules.data.domain.SnapshotValueQueryParam;
|
|
||||||
import com.das.modules.data.service.DataService;
|
|
||||||
import com.googlecode.aviator.exception.StandardError;
|
|
||||||
import com.googlecode.aviator.runtime.function.AbstractFunction;
|
import com.googlecode.aviator.runtime.function.AbstractFunction;
|
||||||
import com.googlecode.aviator.runtime.type.AviatorNil;
|
import com.googlecode.aviator.runtime.type.AviatorNil;
|
||||||
import com.googlecode.aviator.runtime.type.AviatorObject;
|
import com.googlecode.aviator.runtime.type.AviatorObject;
|
||||||
@ -13,8 +8,6 @@ import com.googlecode.aviator.runtime.type.AviatorRuntimeJavaType;
|
|||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -24,9 +17,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* 函数格式: cacheValue(key) 读取缓存值
|
* 函数格式: cacheValue(key) 读取缓存值
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class FunctionGetCacheValue extends AbstractFunction {
|
public class FunctionCacheValue extends AbstractFunction {
|
||||||
private ConcurrentHashMap<String,Double> cacheValues = new ConcurrentHashMap<>();
|
public static final String CACHE_PREFIX = "calc:cache:";
|
||||||
public FunctionGetCacheValue( ) {
|
private AdminRedisTemplate redis = null;
|
||||||
|
public FunctionCacheValue(AdminRedisTemplate redis) {
|
||||||
|
this.redis = redis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,9 +37,22 @@ public class FunctionGetCacheValue extends AbstractFunction {
|
|||||||
Double value = (Double) valData.getValue(env);
|
Double value = (Double) valData.getValue(env);
|
||||||
String scriptName = (String)env.get("G_SCRIPTNAME");
|
String scriptName = (String)env.get("G_SCRIPTNAME");
|
||||||
|
|
||||||
String cacheKey = String.format("%s_%s", scriptName, key);
|
String cacheKey = String.format("%s%s_%s", CACHE_PREFIX, scriptName, key);
|
||||||
cacheValues.put(cacheKey, value);
|
redis.set(cacheKey, value);
|
||||||
|
return AviatorRuntimeJavaType.valueOf(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public AviatorObject call(Map<String, Object> env, AviatorObject keyData, AviatorObject valData, AviatorObject ttlData) {
|
||||||
|
//设备Code
|
||||||
|
String key = (String)keyData.getValue(env);
|
||||||
|
Double value = (Double) valData.getValue(env);
|
||||||
|
Long ttl = (Long) ttlData.getValue(env);
|
||||||
|
String scriptName = (String)env.get("G_SCRIPTNAME");
|
||||||
|
|
||||||
|
String cacheKey = String.format("%s%s_%s", CACHE_PREFIX, scriptName, key);
|
||||||
|
redis.setEx(cacheKey, value, ttl);
|
||||||
return AviatorRuntimeJavaType.valueOf(0);
|
return AviatorRuntimeJavaType.valueOf(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +62,8 @@ public class FunctionGetCacheValue extends AbstractFunction {
|
|||||||
String key = (String)keyData.getValue(env);
|
String key = (String)keyData.getValue(env);
|
||||||
String scriptName = (String)env.get("G_SCRIPTNAME");
|
String scriptName = (String)env.get("G_SCRIPTNAME");
|
||||||
|
|
||||||
String cacheKey = String.format("%s_%s", scriptName, key);
|
String cacheKey = String.format("%s%s_%s", CACHE_PREFIX, scriptName, key);
|
||||||
Double value = cacheValues.get(cacheKey);
|
Double value = redis.get(cacheKey);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return AviatorNil.NIL;
|
return AviatorNil.NIL;
|
||||||
}
|
}
|
@ -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());
|
||||||
//风场信息
|
//风场信息
|
||||||
|
@ -2,10 +2,11 @@ package com.das.modules.calc.service;
|
|||||||
|
|
||||||
import cn.hutool.core.codec.Base64Encoder;
|
import cn.hutool.core.codec.Base64Encoder;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.das.common.utils.AdminRedisTemplate;
|
||||||
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.das.modules.calc.domain.vo.CalcModuleVo;
|
import com.das.modules.calc.domain.vo.CalcModuleVo;
|
||||||
import com.das.modules.calc.functions.FunctionGetCacheValue;
|
import com.das.modules.calc.functions.FunctionCacheValue;
|
||||||
import com.das.modules.calc.functions.FunctionRealData;
|
import com.das.modules.calc.functions.FunctionRealData;
|
||||||
import com.das.modules.calc.functions.FunctionSaveCalcData;
|
import com.das.modules.calc.functions.FunctionSaveCalcData;
|
||||||
import com.das.modules.calc.mapper.CalcModuleMapper;
|
import com.das.modules.calc.mapper.CalcModuleMapper;
|
||||||
@ -17,19 +18,14 @@ 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;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算引擎服务
|
* 计算引擎服务
|
||||||
@ -53,6 +49,15 @@ public class CalcService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
DataService dataService;
|
DataService dataService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AdminRedisTemplate adminRedisTemplate;
|
||||||
|
|
||||||
|
@Value("${calc.debug.enable}")
|
||||||
|
Boolean isDebug;
|
||||||
|
|
||||||
|
@Value("${calc.debug.task-name}")
|
||||||
|
String debugTaskName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算引擎实例
|
* 计算引擎实例
|
||||||
*/
|
*/
|
||||||
@ -70,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("计算模块已启动,请先停止该模块");
|
||||||
@ -112,7 +119,7 @@ public class CalcService {
|
|||||||
FunctionSaveCalcData save = new FunctionSaveCalcData(dataService, cacheService);
|
FunctionSaveCalcData save = new FunctionSaveCalcData(dataService, cacheService);
|
||||||
aviator.addFunction(save);
|
aviator.addFunction(save);
|
||||||
|
|
||||||
FunctionGetCacheValue cache = new FunctionGetCacheValue();
|
FunctionCacheValue cache = new FunctionCacheValue(adminRedisTemplate);
|
||||||
aviator.addFunction(cache);
|
aviator.addFunction(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,4 +806,53 @@ public class TDEngineService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean checkTableExist(String tableName){
|
||||||
|
StringBuffer sb = new StringBuffer(256);
|
||||||
|
sb.append("select count(*) as tablecount from information_schema.ins_tables where table_name = '");
|
||||||
|
sb.append(tableName);
|
||||||
|
sb.append("'");
|
||||||
|
Integer result = null;
|
||||||
|
try (Connection conn = hikariDataSource.getConnection();
|
||||||
|
Statement smt = conn.createStatement();
|
||||||
|
ResultSet rs = smt.executeQuery(sb.toString())) {
|
||||||
|
if (rs.next()) {
|
||||||
|
result = rs.getInt("tablecount");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("检查td表是否存在失败", e);
|
||||||
|
}
|
||||||
|
return result != null && result == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTagDeviceName(String tableName,String deviceName){
|
||||||
|
|
||||||
|
StringBuffer sb = new StringBuffer(256);
|
||||||
|
sb.append("ALTER table ");
|
||||||
|
sb.append(tableName);
|
||||||
|
sb.append(" SET TAG device_name = '").append(deviceName).append("'");
|
||||||
|
|
||||||
|
try (Connection conn = hikariDataSource.getConnection();
|
||||||
|
Statement pstmt = conn.createStatement()) {
|
||||||
|
pstmt.executeUpdate(sb.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("修改Tag值失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTagDeviceCode(String tableName,String deviceCode){
|
||||||
|
StringBuffer sb = new StringBuffer(256);
|
||||||
|
sb.append("ALTER table ");
|
||||||
|
sb.append(tableName);
|
||||||
|
sb.append(" SET TAG device_code = '").append(deviceCode).append("'");
|
||||||
|
|
||||||
|
try (Connection conn = hikariDataSource.getConnection();
|
||||||
|
Statement pstmt = conn.createStatement()) {
|
||||||
|
pstmt.executeUpdate(sb.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("修改Tag值失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import org.springframework.util.StopWatch;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -71,6 +72,10 @@ public class DataServiceImpl implements DataService {
|
|||||||
|
|
||||||
public ConcurrentHashMap<String, Map<String, Integer>> eventLevelMap = new ConcurrentHashMap<>(10000);
|
public ConcurrentHashMap<String, Map<String, Integer>> eventLevelMap = new ConcurrentHashMap<>(10000);
|
||||||
|
|
||||||
|
public ConcurrentHashMap<String, Map<String, String>> stateDescMap = new ConcurrentHashMap<>(10000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取实时数据快照
|
* 读取实时数据快照
|
||||||
* @param paramList 设备id及设备属性列表
|
* @param paramList 设备id及设备属性列表
|
||||||
@ -234,6 +239,7 @@ public class DataServiceImpl implements DataService {
|
|||||||
Map<String, String> calculateFieldList = allIotModelField.stream().filter(field -> field.getAttributeType() == 199).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getDataType, (value1, value2) -> value1));
|
Map<String, String> calculateFieldList = allIotModelField.stream().filter(field -> field.getAttributeType() == 199).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getDataType, (value1, value2) -> value1));
|
||||||
Map<String, String> fieldCodeNameList = allIotModelField.stream().collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getAttributeName, (value1, value2) -> value1));
|
Map<String, String> fieldCodeNameList = allIotModelField.stream().collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getAttributeName, (value1, value2) -> value1));
|
||||||
Map<String, Integer> eventLevelList = allIotModelField.stream().collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getLevel, (value1, value2) -> value1));
|
Map<String, Integer> eventLevelList = allIotModelField.stream().collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getLevel, (value1, value2) -> value1));
|
||||||
|
Map<String, String> stateDescList = allIotModelField.stream().filter(field -> field.getStateDesc() != null).collect(Collectors.toMap(SysIotModelField::getAttributeCode, SysIotModelField::getStateDesc, (value1, value2) -> value1));
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
for (String field : HighModelFieldList.keySet()) {
|
for (String field : HighModelFieldList.keySet()) {
|
||||||
map.put(field, HighModelFieldList.get(field));
|
map.put(field, HighModelFieldList.get(field));
|
||||||
@ -247,6 +253,8 @@ public class DataServiceImpl implements DataService {
|
|||||||
eventLevelMap.put(item.getIotModelCode(),eventLevelList);
|
eventLevelMap.put(item.getIotModelCode(),eventLevelList);
|
||||||
fieldCodeNameMap.put(item.getIotModelCode(),fieldCodeNameList);
|
fieldCodeNameMap.put(item.getIotModelCode(),fieldCodeNameList);
|
||||||
calculateIotFieldMap.put(item.getIotModelCode(), calculateFieldList);
|
calculateIotFieldMap.put(item.getIotModelCode(), calculateFieldList);
|
||||||
|
stateDescMap.put(item.getIotModelCode(),stateDescList);
|
||||||
|
|
||||||
}
|
}
|
||||||
tdEngineService.initIotModel(allIotModel, highIotFieldMap, lowIotFieldMap, calculateIotFieldMap);
|
tdEngineService.initIotModel(allIotModel, highIotFieldMap, lowIotFieldMap, calculateIotFieldMap);
|
||||||
}
|
}
|
||||||
|
@ -75,5 +75,7 @@ public class SysIotModelFieldDto implements Serializable {
|
|||||||
|
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
|
private String stateDesc;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,4 +67,6 @@ public class SysIotModelFieldExcel {
|
|||||||
|
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
|
private String stateDesc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,4 +68,6 @@ public class SysIotModelFieldVo {
|
|||||||
|
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
|
private String stateDesc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,4 +105,10 @@ public class SysIotModelField extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField("level")
|
@TableField("level")
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警描述
|
||||||
|
*/
|
||||||
|
@TableField("statedesc")
|
||||||
|
private String stateDesc;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import com.das.common.utils.SequenceUtils;
|
|||||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||||
import com.das.modules.auth.mapper.SysOrgMapper;
|
import com.das.modules.auth.mapper.SysOrgMapper;
|
||||||
import com.das.modules.cache.service.CacheService;
|
import com.das.modules.cache.service.CacheService;
|
||||||
|
import com.das.modules.data.service.TDEngineService;
|
||||||
import com.das.modules.data.service.impl.DataServiceImpl;
|
import com.das.modules.data.service.impl.DataServiceImpl;
|
||||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||||
import com.das.modules.equipment.domain.excel.SysEquipmentExcel;
|
import com.das.modules.equipment.domain.excel.SysEquipmentExcel;
|
||||||
@ -66,6 +67,9 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CacheService cacheService;
|
private CacheService cacheService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TDEngineService tdEngineService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
public SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||||
//去除空格
|
//去除空格
|
||||||
@ -119,6 +123,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
}
|
}
|
||||||
//更新设备缓存
|
//更新设备缓存
|
||||||
cacheService.getEquipmentCache().refreshDeviceCache(sysEquipment.getId());
|
cacheService.getEquipmentCache().refreshDeviceCache(sysEquipment.getId());
|
||||||
|
if (tdEngineService.checkTableExist("e_"+sysEquipment.getId())){
|
||||||
|
tdEngineService.updateTagDeviceCode("e_"+sysEquipment.getId(),sysEquipment.getCode());
|
||||||
|
tdEngineService.updateTagDeviceName("e_"+sysEquipment.getId(),sysEquipment.getName());
|
||||||
|
}
|
||||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||||
BeanCopyUtils.copy(sysEquipment, sysEquipmentVo);
|
BeanCopyUtils.copy(sysEquipment, sysEquipmentVo);
|
||||||
return sysEquipmentVo;
|
return sysEquipmentVo;
|
||||||
@ -319,6 +327,12 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
}
|
}
|
||||||
//更新设备缓存
|
//更新设备缓存
|
||||||
cacheService.getEquipmentCache().refreshDeviceCache(item.getId());
|
cacheService.getEquipmentCache().refreshDeviceCache(item.getId());
|
||||||
|
|
||||||
|
//更新td表TAG
|
||||||
|
if (tdEngineService.checkTableExist("e_"+item.getId())){
|
||||||
|
tdEngineService.updateTagDeviceCode("e_"+item.getId(),item.getCode());
|
||||||
|
tdEngineService.updateTagDeviceName("e_"+item.getId(),item.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(delSysEquipmentList)) {
|
if (CollectionUtils.isNotEmpty(delSysEquipmentList)) {
|
||||||
|
@ -305,6 +305,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
|||||||
map.put("visible", "是否可见(0:不可见,1:可见)");
|
map.put("visible", "是否可见(0:不可见,1:可见)");
|
||||||
map.put("highSpeed", "*属性频度(0低频属性,1高频属性)");
|
map.put("highSpeed", "*属性频度(0低频属性,1高频属性)");
|
||||||
map.put("level","离散量级别:0提示;1告警;2故障");
|
map.put("level","离散量级别:0提示;1告警;2故障");
|
||||||
|
map.put("stateDesc","告警级别描述");
|
||||||
sheetDTO.setSheetName("物模型属性");
|
sheetDTO.setSheetName("物模型属性");
|
||||||
sheetDTO.setFieldAndAlias(map);
|
sheetDTO.setFieldAndAlias(map);
|
||||||
sheetDTO.setCollection(sysIotModelFieldVoList);
|
sheetDTO.setCollection(sysIotModelFieldVoList);
|
||||||
@ -519,6 +520,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
|||||||
field.setVisible(ObjectUtil.isEmpty(row.get(10)) ? null : Integer.valueOf(row.get(10).toString()));
|
field.setVisible(ObjectUtil.isEmpty(row.get(10)) ? null : Integer.valueOf(row.get(10).toString()));
|
||||||
field.setHighSpeed(Integer.valueOf(row.get(11).toString()));
|
field.setHighSpeed(Integer.valueOf(row.get(11).toString()));
|
||||||
field.setLevel(ObjectUtil.isEmpty(row.get(12)) ? null : Integer.valueOf(row.get(12).toString()));
|
field.setLevel(ObjectUtil.isEmpty(row.get(12)) ? null : Integer.valueOf(row.get(12).toString()));
|
||||||
|
field.setStateDesc(ObjectUtil.isEmpty(row.get(13)) ? null : row.get(13).toString());
|
||||||
field.setIotModelId(Long.valueOf(iotModelId));
|
field.setIotModelId(Long.valueOf(iotModelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,6 +635,16 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (sysIotModelField.getStateDesc() != null){
|
||||||
|
Map<String, String> stateDescMap = dataService.stateDescMap.get(modelCode);
|
||||||
|
if (stateDescMap == null) {
|
||||||
|
Map<String, String> calMap = new HashMap<>();
|
||||||
|
calMap.put(sysIotModelField.getAttributeCode(), sysIotModelField.getStateDesc());
|
||||||
|
dataService.stateDescMap.put(modelCode, calMap);
|
||||||
|
} else {
|
||||||
|
stateDescMap.put(sysIotModelField.getAttributeCode(), sysIotModelField.getStateDesc());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (sysIotModelField.getAttributeType() == 199) {
|
if (sysIotModelField.getAttributeType() == 199) {
|
||||||
Map<String, String> map = dataService.calculateIotFieldMap.get(modelCode);
|
Map<String, String> map = dataService.calculateIotFieldMap.get(modelCode);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
@ -684,6 +696,9 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
|||||||
if (sysIotModelField.getLevel() != null){
|
if (sysIotModelField.getLevel() != null){
|
||||||
dataService.eventLevelMap.remove(sysIotModelField.getAttributeCode());
|
dataService.eventLevelMap.remove(sysIotModelField.getAttributeCode());
|
||||||
}
|
}
|
||||||
|
if (sysIotModelField.getStateDesc() != null){
|
||||||
|
dataService.stateDescMap.remove(sysIotModelField.getAttributeCode());
|
||||||
|
}
|
||||||
if (sysIotModelField.getAttributeType() == 199) {
|
if (sysIotModelField.getAttributeType() == 199) {
|
||||||
Map<String, String> map = dataService.calculateIotFieldMap.get(modelCode);
|
Map<String, String> map = dataService.calculateIotFieldMap.get(modelCode);
|
||||||
map.remove(sysIotModelField.getAttributeCode());
|
map.remove(sysIotModelField.getAttributeCode());
|
||||||
|
@ -369,12 +369,20 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
|
|||||||
deviceEventInfo.setEventType(item.getEventType());
|
deviceEventInfo.setEventType(item.getEventType());
|
||||||
deviceEventInfo.setConfirmed(0);
|
deviceEventInfo.setConfirmed(0);
|
||||||
if (!StringUtils.isEmpty(eventType) && eventType.equals("遥信变位")) {
|
if (!StringUtils.isEmpty(eventType) && eventType.equals("遥信变位")) {
|
||||||
|
String stateDesc = dataService.stateDescMap.get(model).get(item.getAttrCode());
|
||||||
if (item.getAttrValue().equals(0)) {
|
if (item.getAttrValue().equals(0)) {
|
||||||
deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 复归");
|
deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 复归");
|
||||||
|
if (StringUtils.isNotEmpty(stateDesc)){
|
||||||
|
List<String> descList = Arrays.stream(stateDesc.split("\\|")).toList();
|
||||||
|
deviceEventInfo.setEventText(item.getAttrCode()+fieldName + descList.get(0));
|
||||||
|
}
|
||||||
deviceEventInfo.setEventLevel(0);
|
deviceEventInfo.setEventLevel(0);
|
||||||
} else {
|
} else {
|
||||||
deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 动作");
|
deviceEventInfo.setEventText(item.getAttrCode()+fieldName + " 动作");
|
||||||
|
if (StringUtils.isNotEmpty(stateDesc)){
|
||||||
|
List<String> descList = Arrays.stream(stateDesc.split("\\|")).toList();
|
||||||
|
deviceEventInfo.setEventText(item.getAttrCode()+fieldName + descList.get(1));
|
||||||
|
}
|
||||||
Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode());
|
Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode());
|
||||||
log.info("level:{}",level);
|
log.info("level:{}",level);
|
||||||
log.info("fieldname{}",fieldName);
|
log.info("fieldname{}",fieldName);
|
||||||
|
@ -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:
|
||||||
@ -96,5 +102,5 @@ logging:
|
|||||||
|
|
||||||
tdengine:
|
tdengine:
|
||||||
password: taosdata
|
password: taosdata
|
||||||
url: jdbc:TAOS-RS://192.168.109.160:6041/das
|
url: jdbc:TAOS-RS://192.168.109.187:6041/das
|
||||||
username: root
|
username: root
|
@ -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
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@
|
|||||||
<select id="queryFieldByModelId" resultMap="SysIotModelFieldMap">
|
<select id="queryFieldByModelId" resultMap="SysIotModelFieldMap">
|
||||||
select simf.*,sim.iot_model_name as iotModelName,
|
select simf.*,sim.iot_model_name as iotModelName,
|
||||||
sim.iot_model_code from sys_iot_model_field simf left join sys_iot_model sim on simf.iot_model_id = sim.id
|
sim.iot_model_code from sys_iot_model_field simf left join sys_iot_model sim on simf.iot_model_id = sim.id
|
||||||
where simf.iot_model_id = #{id}
|
where simf.iot_model_id = #{id} order by simf.porder asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryServiceByModelId" resultMap="SysIotModelServiceMap">
|
<select id="queryServiceByModelId" resultMap="SysIotModelServiceMap">
|
||||||
select sims.*,sim.iot_model_name as iotModelName,
|
select sims.*,sim.iot_model_name as iotModelName,
|
||||||
sim.iot_model_code from sys_iot_model_service sims left join sys_iot_model sim on sims.iot_model_id = sim.id
|
sim.iot_model_code from sys_iot_model_service sims left join sys_iot_model sim on sims.iot_model_id = sim.id
|
||||||
where sims.iot_model_id = #{id}
|
where sims.iot_model_id = #{id} order by sims.porder asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryIotModelIdByName" resultType="java.lang.Long">
|
<select id="queryIotModelIdByName" resultType="java.lang.Long">
|
||||||
@ -78,7 +78,7 @@
|
|||||||
where se.id = #{id}
|
where se.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<select id="getAllIotModelField" resultType="com.das.modules.equipment.entity.SysIotModelField">
|
<select id="getAllIotModelField" resultType="com.das.modules.equipment.entity.SysIotModelField">
|
||||||
select simf.attribute_name as attributeName, simf.attribute_code as attributeCode,simf.highspeed as highSpeed,simf.datatype as dataType,simf.attribute_type as attributeType,simf.level as level from sys_iot_model_field simf where simf.iot_model_id = #{id} order by simf.attribute_code
|
select simf.attribute_name as attributeName, simf.attribute_code as attributeCode,simf.highspeed as highSpeed,simf.datatype as dataType,simf.attribute_type as attributeType,simf.level as level,simf.stateDesc as stateDesc from sys_iot_model_field simf where simf.iot_model_id = #{id} order by simf.attribute_code
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ const shortcuts = [
|
|||||||
text: '今天',
|
text: '今天',
|
||||||
value: () => {
|
value: () => {
|
||||||
const start = getFormattedDate(0) + ' 00:00:00'
|
const start = getFormattedDate(0) + ' 00:00:00'
|
||||||
const end = new Date()
|
const end = getFormattedDate(0) + ' 23:59:59'
|
||||||
return [start, end]
|
return [start, end]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -200,11 +200,13 @@ const dateValue = ref('')
|
|||||||
const windBlowerValue = ref('')
|
const windBlowerValue = ref('')
|
||||||
const windBlowerList = ref<WindBlowerList[]>([])
|
const windBlowerList = ref<WindBlowerList[]>([])
|
||||||
// 时间
|
// 时间
|
||||||
const timeRange = ref([])
|
const timeRange = ref([]) as any
|
||||||
// 间隔
|
// 间隔
|
||||||
const interval = ref('')
|
const interval = ref('15m')
|
||||||
const intervals = [
|
const intervals = [
|
||||||
|
{ label: '一分钟', value: '1m' },
|
||||||
{ label: '五分钟', value: '5m' },
|
{ label: '五分钟', value: '5m' },
|
||||||
|
{ label: '十分钟', value: '10m' },
|
||||||
{ label: '十五分钟', value: '15m' },
|
{ label: '十五分钟', value: '15m' },
|
||||||
{ label: '一小时', value: '1h' },
|
{ label: '一小时', value: '1h' },
|
||||||
{ label: '一天', value: '1d' },
|
{ label: '一天', value: '1d' },
|
||||||
@ -321,6 +323,7 @@ const queryWindBlower = () => {
|
|||||||
modelId: item.modelId,
|
modelId: item.modelId,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
windBlowerValue.value = windBlowerList.value?.[0].irn
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -450,7 +453,7 @@ const queryHistoryData = () => {
|
|||||||
tableData.push({
|
tableData.push({
|
||||||
name: item,
|
name: item,
|
||||||
times: realResult[item].times,
|
times: realResult[item].times,
|
||||||
value: realResult[item].values,
|
value: realResult[item].values.map((val: any) => (val === 0 ? 0 : val.toFixed(2))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -529,6 +532,7 @@ const timestampToTime = (timestamp: any) => {
|
|||||||
|
|
||||||
getReportTemplateList()
|
getReportTemplateList()
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
timeRange.value = shortcuts[0].value()
|
||||||
queryWindBlower()
|
queryWindBlower()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="report">
|
<div class="report">
|
||||||
<el-container class="mainContainer">
|
<el-container class="mainContainer">
|
||||||
<el-tabs v-model="activeIndex" class="demo-tabs" @tab-click="handleClick">
|
<SingleReport />
|
||||||
|
<!-- <el-tabs v-model="activeIndex" class="demo-tabs" @tab-click="handleClick">
|
||||||
<el-tab-pane label="运行报表" name="1" class="runningReport">
|
<el-tab-pane label="运行报表" name="1" class="runningReport">
|
||||||
<RunningReport v-if="activeIndex == '1'"></RunningReport>
|
<RunningReport v-if="activeIndex == '1'"></RunningReport>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
@ -11,7 +12,7 @@
|
|||||||
<el-tab-pane label="多机报表" name="3" class="mltipleReport">
|
<el-tab-pane label="多机报表" name="3" class="mltipleReport">
|
||||||
<MulipleReport v-if="activeIndex == '3'"></MulipleReport>
|
<MulipleReport v-if="activeIndex == '3'"></MulipleReport>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs> -->
|
||||||
</el-container>
|
</el-container>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -40,7 +41,7 @@ const handleClick = (val: any) => {
|
|||||||
.mainContainer {
|
.mainContainer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0 20px;
|
padding: 20px;
|
||||||
.el-tabs {
|
.el-tabs {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
--el-tabs-header-height: 60px;
|
--el-tabs-header-height: 60px;
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
row-key="id"
|
row-key="id"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
<el-table-column prop="name" label="测点名称" width="120" />
|
<el-table-column prop="name" label="风机名称" width="120" />
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-table
|
<el-table
|
||||||
:data="tableDataRight"
|
:data="tableDataRight"
|
||||||
@ -59,7 +59,7 @@
|
|||||||
row-key="id"
|
row-key="id"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
<el-table-column prop="name" label="测点名称" width="120" />
|
<el-table-column prop="name" label="风机名称" width="120" />
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -79,7 +79,7 @@
|
|||||||
:data="attrTableData"
|
:data="attrTableData"
|
||||||
ref="attributeTableRef"
|
ref="attributeTableRef"
|
||||||
@select="selectTable"
|
@select="selectTable"
|
||||||
@selectAll="selectAllTable"
|
@selectAll="selectTable"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
class="attrtable"
|
class="attrtable"
|
||||||
>
|
>
|
||||||
@ -200,7 +200,7 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
const tableDataLeft = ref([])
|
const tableDataLeft = ref([])
|
||||||
const tableDataRight = ref([])
|
const tableDataRight = ref([])
|
||||||
|
const iotModelId = ref('')
|
||||||
const selectedLeft = ref([])
|
const selectedLeft = ref([])
|
||||||
const selectedRight = ref([])
|
const selectedRight = ref([])
|
||||||
|
|
||||||
@ -213,9 +213,12 @@ const queryWindTurbines = () => {
|
|||||||
queryWindTurbinesPages().then((res) => {
|
queryWindTurbinesPages().then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
const resData = res.data
|
const resData = res.data
|
||||||
const middleIndex = Math.ceil(resData.length / 2)
|
if (resData.length) {
|
||||||
tableDataLeft.value = resData.slice(0, middleIndex)
|
iotModelId.value = resData[0]['modelId']
|
||||||
tableDataRight.value = resData.slice(middleIndex)
|
const middleIndex = Math.ceil(resData.length / 2)
|
||||||
|
tableDataLeft.value = resData.slice(0, middleIndex)
|
||||||
|
tableDataRight.value = resData.slice(middleIndex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -233,7 +236,7 @@ const getcurrentPage = () => {
|
|||||||
|
|
||||||
const getCompleteData = () => {
|
const getCompleteData = () => {
|
||||||
const requestData: any = {
|
const requestData: any = {
|
||||||
iotModelId: '',
|
iotModelId: iotModelId.value,
|
||||||
pageNum: pageSetting.current,
|
pageNum: pageSetting.current,
|
||||||
pageSize: pageSetting.pageSize,
|
pageSize: pageSetting.pageSize,
|
||||||
attributeType: radioActiveName.value,
|
attributeType: radioActiveName.value,
|
||||||
@ -271,30 +274,18 @@ const initSelect = () => {
|
|||||||
const multipleSelection: any = ref([])
|
const multipleSelection: any = ref([])
|
||||||
|
|
||||||
const selectTable = (section: any) => {
|
const selectTable = (section: any) => {
|
||||||
const defaultCode = multipleSelection.value.map((item: any) => item.attributeCode)
|
const allCode = attrTableData.value.map((item: any) => {
|
||||||
const addSection = section
|
return item.attributeCode
|
||||||
.filter((item: any) => !defaultCode.includes(item.attributeCode))
|
})
|
||||||
.map((item: any) => {
|
const extraCode = multipleSelection.value.filter((item: any) => !allCode.includes(item.attributeCode))
|
||||||
return {
|
const setionMap = section.map((item: any) => {
|
||||||
attributeName: item.attributeName,
|
return {
|
||||||
attributeCode: item.attributeCode,
|
attributeName: item.attributeName,
|
||||||
unit: item.unit,
|
attributeCode: item.attributeCode,
|
||||||
}
|
unit: item.unit,
|
||||||
})
|
}
|
||||||
multipleSelection.value = [...multipleSelection.value, ...addSection]
|
})
|
||||||
}
|
multipleSelection.value = [...extraCode, ...setionMap]
|
||||||
const selectAllTable = (section: any) => {
|
|
||||||
const defaultCode = multipleSelection.value.map((item: any) => item.attributeCode)
|
|
||||||
const addSection = section
|
|
||||||
.filter((item: any) => !defaultCode.includes(item.attributeCode))
|
|
||||||
.map((item: any) => {
|
|
||||||
return {
|
|
||||||
attributeName: item.attributeName,
|
|
||||||
attributeCode: item.attributeCode,
|
|
||||||
unit: item.unit,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
multipleSelection.value = [...multipleSelection.value, ...addSection]
|
|
||||||
}
|
}
|
||||||
const attrTableData = ref([])
|
const attrTableData = ref([])
|
||||||
|
|
||||||
@ -364,6 +355,7 @@ const getDateRange = (type: 'week' | 'month') => {
|
|||||||
|
|
||||||
const openMeasure = () => {
|
const openMeasure = () => {
|
||||||
showMeasure.value = true
|
showMeasure.value = true
|
||||||
|
pageSetting.current = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelectionChange1 = (val: any) => {
|
const handleSelectionChange1 = (val: any) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user