优化接口
This commit is contained in:
parent
fb0f7bd4b5
commit
c8c9260dee
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +0,0 @@
|
|||||||
.idea
|
|
||||||
das-dn/.vscode
|
|
||||||
ui/**/dist
|
|
||||||
das/**/target
|
|
13
das/src/main/java/com/das/modules/cache/domain/IotFieldInfoCache.java
vendored
Normal file
13
das/src/main/java/com/das/modules/cache/domain/IotFieldInfoCache.java
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.das.modules.cache.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IotFieldInfoCache {
|
||||||
|
private String attributeCode;
|
||||||
|
private String attributeName;
|
||||||
|
private Integer attributeType;
|
||||||
|
private Integer porder;
|
||||||
|
private Integer highspeed;
|
||||||
|
private Integer datatype;
|
||||||
|
}
|
12
das/src/main/java/com/das/modules/cache/domain/IotModelInfoCache.java
vendored
Normal file
12
das/src/main/java/com/das/modules/cache/domain/IotModelInfoCache.java
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package com.das.modules.cache.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IotModelInfoCache {
|
||||||
|
private Long iotModelId;
|
||||||
|
private String iodModelCode;
|
||||||
|
private ConcurrentHashMap<String,IotFieldInfoCache> fieldInfoCache;
|
||||||
|
}
|
@ -10,4 +10,10 @@ public interface CacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
EquipmentCache getEquipmentCache();
|
EquipmentCache getEquipmentCache();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取物模型缓存接口
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IotModelCache getIotModelCache();
|
||||||
}
|
}
|
||||||
|
@ -33,4 +33,10 @@ public interface EquipmentCache {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
DeviceInfoCache getDeviceInfoCacheById(Long deviceId);
|
DeviceInfoCache getDeviceInfoCacheById(Long deviceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除指定设备缓存
|
||||||
|
* @param deviceId
|
||||||
|
*/
|
||||||
|
void removeDeviceCache(Long deviceId);
|
||||||
}
|
}
|
||||||
|
5
das/src/main/java/com/das/modules/cache/service/IotModelCache.java
vendored
Normal file
5
das/src/main/java/com/das/modules/cache/service/IotModelCache.java
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package com.das.modules.cache.service;
|
||||||
|
|
||||||
|
public interface IotModelCache {
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.das.modules.cache.service.impl;
|
|||||||
|
|
||||||
import com.das.modules.cache.service.CacheService;
|
import com.das.modules.cache.service.CacheService;
|
||||||
import com.das.modules.cache.service.EquipmentCache;
|
import com.das.modules.cache.service.EquipmentCache;
|
||||||
|
import com.das.modules.cache.service.IotModelCache;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -9,10 +10,20 @@ import org.springframework.stereotype.Service;
|
|||||||
public class CacheServiceImpl implements CacheService {
|
public class CacheServiceImpl implements CacheService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
EquipmentCache equipmentCache;;
|
EquipmentCache equipmentCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IotModelCache iotModelCache;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EquipmentCache getEquipmentCache() {
|
public EquipmentCache getEquipmentCache() {
|
||||||
return equipmentCache;
|
return equipmentCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IotModelCache getIotModelCache() {
|
||||||
|
return iotModelCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class EquipmentCacheImpl implements EquipmentCache {
|
public abstract class EquipmentCacheImpl implements EquipmentCache {
|
||||||
@Autowired
|
@Autowired
|
||||||
SysEquipmentMapper sysEquipmentMapper;
|
SysEquipmentMapper sysEquipmentMapper;
|
||||||
|
|
||||||
@ -110,4 +110,13 @@ public class EquipmentCacheImpl implements EquipmentCache {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeDeviceCache(Long deviceId) {
|
||||||
|
Integer index = deviceIdIndex.get(deviceId);
|
||||||
|
if (index != null) {
|
||||||
|
deviceInfoCaches.remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
24
das/src/main/java/com/das/modules/cache/service/impl/IotModelCacheImpl.java
vendored
Normal file
24
das/src/main/java/com/das/modules/cache/service/impl/IotModelCacheImpl.java
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.das.modules.cache.service.impl;
|
||||||
|
|
||||||
|
import com.das.modules.cache.service.IotModelCache;
|
||||||
|
import com.das.modules.equipment.mapper.SysIotModelMapper;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import jakarta.annotation.PreDestroy;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class IotModelCacheImpl implements IotModelCache {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SysIotModelMapper sysIotModelMapper;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init(){
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreDestroy
|
||||||
|
public void destroy(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package com.das.modules.calc.functions;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
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.runtime.function.AbstractFunction;
|
||||||
|
import com.googlecode.aviator.runtime.type.AviatorNil;
|
||||||
|
import com.googlecode.aviator.runtime.type.AviatorObject;
|
||||||
|
import com.googlecode.aviator.runtime.type.AviatorRuntimeJavaType;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aviator扩展函数 - 获取时间维度内最早的一条数据
|
||||||
|
* 函数格式: topv(deviceId, attr, timedim)
|
||||||
|
* timedim: day - 天, month - 月, year - 年
|
||||||
|
* 返回值:数值, nil - 获取错误
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class FunctionTopValue extends AbstractFunction {
|
||||||
|
|
||||||
|
private DataService dataService = null;
|
||||||
|
private CacheService cacheService = null;
|
||||||
|
|
||||||
|
private ConcurrentHashMap<String,CacheValue> cacheValues = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public FunctionTopValue(DataService dataService, CacheService cacheService) {
|
||||||
|
this.dataService = dataService;
|
||||||
|
this.cacheService = cacheService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "topv";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AviatorObject call(Map<String, Object> env, AviatorObject deviceCode, AviatorObject attr, AviatorObject timeDim) {
|
||||||
|
//设备Code
|
||||||
|
String code = (String)deviceCode.getValue(env);
|
||||||
|
String attrName = (String)attr.getValue(env);
|
||||||
|
String timeDimName = (String)timeDim.getValue(env);
|
||||||
|
|
||||||
|
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code);
|
||||||
|
if (deviceInfoCache == null) {
|
||||||
|
return AviatorNil.NIL;
|
||||||
|
}
|
||||||
|
String key = String.format("%d_%s_%s", deviceInfoCache.getDeviceId(), attrName, timeDimName);
|
||||||
|
//根据维度,获取维度时间
|
||||||
|
Date curTimeValue = null;
|
||||||
|
switch (timeDimName) {
|
||||||
|
case "day":
|
||||||
|
curTimeValue = DateUtil.beginOfDay(DateUtil.date());
|
||||||
|
break;
|
||||||
|
case "month":
|
||||||
|
curTimeValue = DateUtil.beginOfMonth(DateUtil.date());
|
||||||
|
break;
|
||||||
|
case "year":
|
||||||
|
curTimeValue = DateUtil.beginOfYear(DateUtil.date());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return AviatorNil.NIL;
|
||||||
|
}
|
||||||
|
CacheValue cacheValue = cacheValues.get(key);
|
||||||
|
if (cacheValue != null) {
|
||||||
|
//缓存中存在,检查是否过期
|
||||||
|
if (cacheValue.getCurTimeValue() != null && DateUtil.compare(cacheValue.getCurTimeValue(), curTimeValue) == 0) {
|
||||||
|
return AviatorRuntimeJavaType.valueOf(cacheValue.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//未找到缓存,查询时序API获取数据
|
||||||
|
dataService.querySnapshotValues()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
class CacheValue{
|
||||||
|
private Double value;
|
||||||
|
private Date curTimeValue;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ public class CalcJob implements Job {
|
|||||||
}
|
}
|
||||||
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());
|
||||||
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("G_DEVICES", cacheService.getEquipmentCache().getDevicesCache());
|
||||||
|
@ -126,6 +126,7 @@ public class CalcService {
|
|||||||
try{
|
try{
|
||||||
//预编译脚本
|
//预编译脚本
|
||||||
aviator.compile(scriptModule.getName(), scriptModule.getScript(), true);
|
aviator.compile(scriptModule.getName(), scriptModule.getScript(), true);
|
||||||
|
log.info("[预编译脚本] - {}", scriptModule.getName());
|
||||||
startCalcJob(scriptModule);
|
startCalcJob(scriptModule);
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (Exception e){
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.das.modules.data.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RTValue {
|
||||||
|
private Object value;
|
||||||
|
private Long time;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.das.modules.data.service;
|
package com.das.modules.data.service;
|
||||||
|
|
||||||
|
import com.das.modules.data.domain.RTValue;
|
||||||
import com.das.modules.data.domain.SnapshotValueQueryParam;
|
import com.das.modules.data.domain.SnapshotValueQueryParam;
|
||||||
import com.das.modules.data.domain.TSValueQueryParam;
|
import com.das.modules.data.domain.TSValueQueryParam;
|
||||||
import com.das.modules.node.domain.bo.CalculateRTData;
|
import com.das.modules.node.domain.bo.CalculateRTData;
|
||||||
@ -17,5 +18,5 @@ public interface DataService {
|
|||||||
|
|
||||||
void updateCalFieldData(List<CalculateRTData> values);
|
void updateCalFieldData(List<CalculateRTData> values);
|
||||||
|
|
||||||
|
Double getTimeTopValue(Long devcieId, String attr, long startTime, long endTime);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.ListUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.das.common.utils.PageDataInfo;
|
import com.das.common.utils.PageDataInfo;
|
||||||
import com.das.modules.data.domain.DeviceEventInfo;
|
import com.das.modules.data.domain.DeviceEventInfo;
|
||||||
|
import com.das.modules.data.domain.RTValue;
|
||||||
import com.das.modules.equipment.domain.vo.IotModelFieldVo;
|
import com.das.modules.equipment.domain.vo.IotModelFieldVo;
|
||||||
import com.das.modules.node.domain.bo.CalculateRTData;
|
import com.das.modules.node.domain.bo.CalculateRTData;
|
||||||
import com.das.modules.node.domain.bo.RTData;
|
import com.das.modules.node.domain.bo.RTData;
|
||||||
@ -782,4 +783,27 @@ public class TDEngineService {
|
|||||||
hikariDataSource.close();
|
hikariDataSource.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Double getTimeTopValue(String tableName, String attr, long startTime, long endTime) {
|
||||||
|
StringBuffer sb = new StringBuffer(256);
|
||||||
|
sb.append("select ");
|
||||||
|
sb.append("first(");
|
||||||
|
sb.append(attr);
|
||||||
|
sb.append(") as value");
|
||||||
|
sb.append(" from ");
|
||||||
|
sb.append(tableName);
|
||||||
|
sb.append(" where ");
|
||||||
|
sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime, endTime));
|
||||||
|
Double result = null;
|
||||||
|
try (Connection conn = hikariDataSource.getConnection();
|
||||||
|
Statement smt = conn.createStatement();
|
||||||
|
ResultSet rs = smt.executeQuery(sb.toString())) {
|
||||||
|
if (rs.next()) {
|
||||||
|
result = rs.getDouble("value");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取数据异常", e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,10 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import com.das.common.exceptions.ServiceException;
|
import com.das.common.exceptions.ServiceException;
|
||||||
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.cache.service.EquipmentCache;
|
||||||
|
import com.das.modules.data.domain.RTValue;
|
||||||
import com.das.modules.data.domain.SnapshotValueQueryParam;
|
import com.das.modules.data.domain.SnapshotValueQueryParam;
|
||||||
import com.das.modules.data.domain.TSValueQueryParam;
|
import com.das.modules.data.domain.TSValueQueryParam;
|
||||||
import com.das.modules.data.service.DataService;
|
import com.das.modules.data.service.DataService;
|
||||||
@ -26,7 +30,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class DataServiceImpl implements DataService {
|
public abstract class DataServiceImpl implements DataService {
|
||||||
|
|
||||||
public static final int COMMIT_COUNT = 1000;
|
public static final int COMMIT_COUNT = 1000;
|
||||||
|
|
||||||
@ -45,6 +49,9 @@ public class DataServiceImpl implements DataService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
SysIotModelMapper sysIotModelMapper;
|
SysIotModelMapper sysIotModelMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CacheService cacheService;
|
||||||
|
|
||||||
//key:deviceId value:modelCode
|
//key:deviceId value:modelCode
|
||||||
public ConcurrentHashMap<String, String> deviceModelMap = new ConcurrentHashMap<>(10000);
|
public ConcurrentHashMap<String, String> deviceModelMap = new ConcurrentHashMap<>(10000);
|
||||||
|
|
||||||
@ -236,4 +243,21 @@ public class DataServiceImpl implements DataService {
|
|||||||
tdEngineService.initIotModel(allIotModel, highIotFieldMap, lowIotFieldMap, calculateIotFieldMap);
|
tdEngineService.initIotModel(allIotModel, highIotFieldMap, lowIotFieldMap, calculateIotFieldMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定时间区间内的最早的数据
|
||||||
|
* @param devcieId
|
||||||
|
* @param attr
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Double getTimeTopValue(Long devcieId, String attr, long startTime, long endTime){
|
||||||
|
DeviceInfoCache deviceInfoCacheById = cacheService.getEquipmentCache().getDeviceInfoCacheById(devcieId);
|
||||||
|
if (deviceInfoCacheById == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String tableName = "";
|
||||||
|
return tdEngineService.getTimeTopValue(tableName, attr, startTime, endTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import com.das.common.utils.PageQuery;
|
|||||||
import com.das.common.utils.SequenceUtils;
|
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.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;
|
||||||
@ -62,6 +63,9 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DataServiceImpl dataService;
|
private DataServiceImpl dataService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CacheService cacheService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
public SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||||
//去除空格
|
//去除空格
|
||||||
@ -84,6 +88,8 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
if (sysEquipment.getIotModelId() != null){
|
if (sysEquipment.getIotModelId() != null){
|
||||||
dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
||||||
}
|
}
|
||||||
|
//更新设备缓存
|
||||||
|
cacheService.getEquipmentCache().refreshDeviceCache(sysEquipment.getId());
|
||||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||||
BeanCopyUtils.copy(sysEquipment, sysEquipmentVo);
|
BeanCopyUtils.copy(sysEquipment, sysEquipmentVo);
|
||||||
return sysEquipmentVo;
|
return sysEquipmentVo;
|
||||||
@ -111,6 +117,8 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
if (oldModelSysEquipInfo.getIotModelId() == null && sysEquipment.getIotModelId() != null){
|
if (oldModelSysEquipInfo.getIotModelId() == null && sysEquipment.getIotModelId() != null){
|
||||||
dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
||||||
}
|
}
|
||||||
|
//更新设备缓存
|
||||||
|
cacheService.getEquipmentCache().refreshDeviceCache(sysEquipment.getId());
|
||||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||||
BeanCopyUtils.copy(sysEquipment, sysEquipmentVo);
|
BeanCopyUtils.copy(sysEquipment, sysEquipmentVo);
|
||||||
return sysEquipmentVo;
|
return sysEquipmentVo;
|
||||||
@ -124,6 +132,8 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
}
|
}
|
||||||
sysEquipmentMapper.deleteById(sysEquipmentDto.getId());
|
sysEquipmentMapper.deleteById(sysEquipmentDto.getId());
|
||||||
//删除缓存
|
//删除缓存
|
||||||
|
//更新设备缓存
|
||||||
|
cacheService.getEquipmentCache().refreshDeviceCache(sysEquipmentDto.getId());
|
||||||
dataService.deviceModelMap.remove(sysEquipmentDto.getId().toString());
|
dataService.deviceModelMap.remove(sysEquipmentDto.getId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,6 +307,8 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
String modelCode = dataService.iotModelMap.get(item.getIotModelId().toString());
|
String modelCode = dataService.iotModelMap.get(item.getIotModelId().toString());
|
||||||
dataService.deviceModelMap.put(item.getId().toString(),modelCode);
|
dataService.deviceModelMap.put(item.getId().toString(),modelCode);
|
||||||
}
|
}
|
||||||
|
//更新设备缓存
|
||||||
|
cacheService.getEquipmentCache().refreshDeviceCache(item.getId());
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(updateSysEquipmentList)) {
|
if (CollectionUtils.isNotEmpty(updateSysEquipmentList)) {
|
||||||
sysEquipmentMapper.updateBatchById(updateSysEquipmentList);
|
sysEquipmentMapper.updateBatchById(updateSysEquipmentList);
|
||||||
@ -305,16 +317,17 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
String modelCode = dataService.iotModelMap.get(item.getIotModelId().toString());
|
String modelCode = dataService.iotModelMap.get(item.getIotModelId().toString());
|
||||||
dataService.deviceModelMap.put(item.getId().toString(),modelCode);
|
dataService.deviceModelMap.put(item.getId().toString(),modelCode);
|
||||||
}
|
}
|
||||||
|
//更新设备缓存
|
||||||
|
cacheService.getEquipmentCache().refreshDeviceCache(item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(delSysEquipmentList)) {
|
if (CollectionUtils.isNotEmpty(delSysEquipmentList)) {
|
||||||
// 删除设备
|
// 删除设备
|
||||||
sysEquipmentMapper.deleteBatchIds(delSysEquipmentList);
|
sysEquipmentMapper.deleteBatchIds(delSysEquipmentList);
|
||||||
for (SysEquipment item : updateSysEquipmentList){
|
for (SysEquipment item : delSysEquipmentList){
|
||||||
if (item.getIotModelId() != null){
|
dataService.deviceModelMap.remove(item.getId().toString());
|
||||||
String modelCode = dataService.iotModelMap.get(item.getIotModelId().toString());
|
//更新设备缓存
|
||||||
dataService.deviceModelMap.put(item.getId().toString(),modelCode);
|
cacheService.getEquipmentCache().removeDeviceCache(item.getId());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,16 +40,16 @@ spring:
|
|||||||
# 多个文件总大小
|
# 多个文件总大小
|
||||||
max-request-size: 2048MB
|
max-request-size: 2048MB
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:postgresql://192.168.109.102:5432/das
|
url: jdbc:postgresql://192.168.109.187:5432/das
|
||||||
username: das
|
username: das
|
||||||
password: qwaszx12
|
password: qwaszx12
|
||||||
# # redis相关配置
|
# # redis相关配置
|
||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
host: 192.168.109.195
|
host: 192.168.109.187
|
||||||
database: 0
|
database: 0
|
||||||
port: 6379
|
port: 6379
|
||||||
password:
|
password: zaq12WSX
|
||||||
client-type: lettuce
|
client-type: lettuce
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user