feat: 装置增加typePoint信息

haikang
huangfeng 8 months ago
parent ddfa9cb366
commit 84929f6b3f

@ -88,6 +88,8 @@ public class NSensor {
@Transient
HashMap<String, String> lastData;
@Transient
List<ModevTypePoint> typePoints;
public String addPoint(NPoint point) {
if (points == null) {

@ -9,6 +9,8 @@ import com.xydl.cac.service.ModevTypePointService;
import com.xydl.cac.service.UnitService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -29,6 +31,7 @@ public class ModevTypePointServiceImpl implements ModevTypePointService {
WarnRuleRepository ruleRepository;
@Override
@Cacheable(value = "typePoint", key = "#modevtypeId")
public List<ModevTypePoint> listAll(Integer modevtypeId) {
List<ModevTypePoint> list = repository.findByModevtypeId(modevtypeId);
for (ModevTypePoint point : list) {
@ -40,6 +43,7 @@ public class ModevTypePointServiceImpl implements ModevTypePointService {
}
@Override
@CacheEvict(cacheNames = {"typePoint"}, allEntries = true)
public ModevTypePoint add(ModevTypePoint item) throws Exception {
item.setId(null);
List<ModevTypePoint> list = repository.findByModevtypeIdAndField(item.getModevtypeId(), item.getField());
@ -50,6 +54,7 @@ public class ModevTypePointServiceImpl implements ModevTypePointService {
}
@Override
@CacheEvict(cacheNames = {"typePoint"}, allEntries = true)
public void delete(Integer id) throws Exception {
List<WarnRule> list = ruleRepository.findByModevtypePointId(id);
if (!CollectionUtils.isEmpty(list)) {

@ -78,6 +78,8 @@ public class NSensorServiceImpl implements NSensorService {
if (type.getId().equals(sensor.getTypeId())) {
sensor.setTypeName(type.getMc());
sensor.setTableName(type.getTablename());
List<ModevTypePoint> points = modevTypePointService.listAll(sensor.getTypeId());
sensor.setTypePoints(points);
}
}
HashMap<String, String> map = StaticVariable.sensorLastDataMap.get(sensor.getDevId());

@ -6,6 +6,7 @@ import com.xydl.cac.model.StaticVariable;
import com.xydl.cac.repository.UnitRepository;
import com.xydl.cac.service.UnitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -27,6 +28,7 @@ public class UnitServiceImpl implements UnitService {
}
@Override
@CacheEvict(cacheNames = {"typePoint"}, allEntries = true)
public Unit add(Unit item) throws Exception {
item.setId(null);
List<Unit> list = repository.findByField(item.getField());
@ -38,12 +40,14 @@ public class UnitServiceImpl implements UnitService {
}
@Override
@CacheEvict(cacheNames = {"typePoint"}, allEntries = true)
public void update(Unit item) throws Exception {
repository.save(item);
StaticVariable.unit_Cache.clear();
}
@Override
@CacheEvict(cacheNames = {"typePoint"}, allEntries = true)
public void delete(Integer id) {
repository.deleteById(id);
StaticVariable.unit_Cache.clear();

Loading…
Cancel
Save