diff --git a/das-dn/third_party/AdsLib/Sockets.cpp b/das-dn/third_party/AdsLib/Sockets.cpp index 57cd12c0..981591f3 100644 --- a/das-dn/third_party/AdsLib/Sockets.cpp +++ b/das-dn/third_party/AdsLib/Sockets.cpp @@ -218,6 +218,9 @@ size_t Socket::write(const Frame& frame) const LOG_ERROR("frame length: " << frame.size() << " exceeds maximum length for sockets"); return 0; } + if (m_Socket == INVALID_SOCKET) return 0; + if (m_DestAddr == 0) return 0; + if (m_DestAddrLen <= 0) return 0; const int bufferLength = static_cast(frame.size()); const char* const buffer = reinterpret_cast(frame.data()); diff --git a/das/src/main/java/com/das/modules/cache/domain/WindSpeedCoefValue.java b/das/src/main/java/com/das/modules/cache/domain/WindSpeedCoefValue.java new file mode 100644 index 00000000..8e901644 --- /dev/null +++ b/das/src/main/java/com/das/modules/cache/domain/WindSpeedCoefValue.java @@ -0,0 +1,11 @@ +package com.das.modules.cache.domain; + +import lombok.Data; + +@Data +public class WindSpeedCoefValue { + private Double minValue; + private Double maxValue; + private Double coef; + private Double base; +} diff --git a/das/src/main/java/com/das/modules/cache/service/CacheService.java b/das/src/main/java/com/das/modules/cache/service/CacheService.java index 9298c642..5784e2ab 100644 --- a/das/src/main/java/com/das/modules/cache/service/CacheService.java +++ b/das/src/main/java/com/das/modules/cache/service/CacheService.java @@ -16,4 +16,6 @@ public interface CacheService { * @return */ IotModelCache getIotModelCache(); + + CalcCache getCalcCache(); } diff --git a/das/src/main/java/com/das/modules/cache/service/CalcCache.java b/das/src/main/java/com/das/modules/cache/service/CalcCache.java new file mode 100644 index 00000000..821a88ac --- /dev/null +++ b/das/src/main/java/com/das/modules/cache/service/CalcCache.java @@ -0,0 +1,10 @@ +package com.das.modules.cache.service; + +import com.das.modules.cache.domain.WindSpeedCoefValue; + +import java.util.List; + +public interface CalcCache { + List getWindSpeedCoef(Long deviceId); + void refreshWindSpeedCoef(); +} diff --git a/das/src/main/java/com/das/modules/cache/service/impl/CacheServiceImpl.java b/das/src/main/java/com/das/modules/cache/service/impl/CacheServiceImpl.java index e22d5972..3042f7bd 100644 --- a/das/src/main/java/com/das/modules/cache/service/impl/CacheServiceImpl.java +++ b/das/src/main/java/com/das/modules/cache/service/impl/CacheServiceImpl.java @@ -1,6 +1,7 @@ package com.das.modules.cache.service.impl; import com.das.modules.cache.service.CacheService; +import com.das.modules.cache.service.CalcCache; import com.das.modules.cache.service.EquipmentCache; import com.das.modules.cache.service.IotModelCache; import org.springframework.beans.factory.annotation.Autowired; @@ -15,6 +16,9 @@ public class CacheServiceImpl implements CacheService { @Autowired IotModelCache iotModelCache; + @Autowired + CalcCache calcCache; + @Override public EquipmentCache getEquipmentCache() { return equipmentCache; @@ -25,5 +29,10 @@ public class CacheServiceImpl implements CacheService { return iotModelCache; } + @Override + public CalcCache getCalcCache() { + return calcCache; + } + } diff --git a/das/src/main/java/com/das/modules/cache/service/impl/CalcCacheImpl.java b/das/src/main/java/com/das/modules/cache/service/impl/CalcCacheImpl.java new file mode 100644 index 00000000..69789de9 --- /dev/null +++ b/das/src/main/java/com/das/modules/cache/service/impl/CalcCacheImpl.java @@ -0,0 +1,50 @@ +package com.das.modules.cache.service.impl; + +import com.das.modules.cache.domain.WindSpeedCoefValue; +import com.das.modules.cache.service.CalcCache; +import com.das.modules.page.domian.dto.SysPowerCurveFactorDto; +import com.das.modules.page.domian.vo.SysPowerCurveFactorVo; +import com.das.modules.page.mapper.SysPowerCurveFactorMapper; +import jakarta.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +@Service +public class CalcCacheImpl implements CalcCache { + + @Autowired + SysPowerCurveFactorMapper sysPowerCurveFactorMapper; + + private ConcurrentHashMap> windSpeedCoefMap = new ConcurrentHashMap<>(); + + @PostConstruct + private void init(){ + refreshWindSpeedCoef(); + } + + @Override + public List getWindSpeedCoef(Long deviceId) { + return windSpeedCoefMap.get(deviceId); + } + + @Override + public void refreshWindSpeedCoef() { + List sysPowerCurveFactorVos = sysPowerCurveFactorMapper.querySysPowerCurveFactorList(new SysPowerCurveFactorDto()); + for (SysPowerCurveFactorVo sysPowerCurveFactorVo : sysPowerCurveFactorVos) { + WindSpeedCoefValue windSpeedCoefValue = new WindSpeedCoefValue(); + windSpeedCoefValue.setMinValue(sysPowerCurveFactorVo.getSpeedMin()); + windSpeedCoefValue.setMaxValue(sysPowerCurveFactorVo.getSpeedMax()); + windSpeedCoefValue.setCoef(sysPowerCurveFactorVo.getFactorK()); + windSpeedCoefValue.setBase(sysPowerCurveFactorVo.getFactorB()); + List windSpeedCoefValues = windSpeedCoefMap.get(sysPowerCurveFactorVo.getTurbineId()); + if (windSpeedCoefValues == null) { + windSpeedCoefValues = new java.util.ArrayList<>(); + } + windSpeedCoefValues.add(windSpeedCoefValue); + windSpeedCoefMap.put(sysPowerCurveFactorVo.getTurbineId(), windSpeedCoefValues); + } + } +} diff --git a/das/src/main/java/com/das/modules/calc/functions/FunctionWindSpeedFactor.java b/das/src/main/java/com/das/modules/calc/functions/FunctionWindSpeedFactor.java new file mode 100644 index 00000000..2765024b --- /dev/null +++ b/das/src/main/java/com/das/modules/calc/functions/FunctionWindSpeedFactor.java @@ -0,0 +1,59 @@ +package com.das.modules.calc.functions; + +import cn.hutool.core.collection.CollectionUtil; +import com.das.modules.cache.domain.DeviceInfoCache; +import com.das.modules.cache.domain.WindSpeedCoefValue; +import com.das.modules.cache.service.CacheService; +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.extern.slf4j.Slf4j; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * Aviator扩展函数 - 获取时间维度内平均 + * 函数格式: avg(deviceId, attr, timedim) + * timedim: day - 天, month - 月, year - 年 + * 返回值:数值, nil - 获取错误 + */ +@Slf4j +public class FunctionWindSpeedFactor extends AbstractFunction { + + private DataService dataService = null; + private CacheService cacheService = null; + + + public FunctionWindSpeedFactor(DataService dataService, CacheService cacheService) { + this.dataService = dataService; + this.cacheService = cacheService; + } + + @Override + public String getName() { + return "windSpeedFactor"; + } + + @Override + public AviatorObject call(Map env, AviatorObject deviceCode) { + //设备Code + String code = (String)deviceCode.getValue(env); + + DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code); + if (deviceInfoCache == null) { + return AviatorNil.NIL; + } + + List windSpeedCoef = cacheService.getCalcCache().getWindSpeedCoef(deviceInfoCache.getDeviceId()); + if (CollectionUtil.isEmpty(windSpeedCoef)){ + return AviatorNil.NIL; + } + //未找到缓存,查询时序API获取数据 + return AviatorRuntimeJavaType.valueOf(windSpeedCoef); + } + +} diff --git a/das/src/main/java/com/das/modules/page/service/impl/WindSpeedCorrectServiceImpl.java b/das/src/main/java/com/das/modules/page/service/impl/WindSpeedCorrectServiceImpl.java index c355fc00..b1d40044 100644 --- a/das/src/main/java/com/das/modules/page/service/impl/WindSpeedCorrectServiceImpl.java +++ b/das/src/main/java/com/das/modules/page/service/impl/WindSpeedCorrectServiceImpl.java @@ -12,6 +12,8 @@ import com.das.common.utils.BeanCopyUtils; import com.das.common.utils.PageDataInfo; import com.das.common.utils.PageQuery; import com.das.modules.auth.domain.vo.SysUserVo; +import com.das.modules.cache.domain.WindSpeedCoefValue; +import com.das.modules.cache.service.CacheService; import com.das.modules.equipment.entity.SysEquipment; import com.das.modules.equipment.mapper.SysEquipmentMapper; import com.das.modules.page.domian.dto.IntervalDto; @@ -52,6 +54,9 @@ public class WindSpeedCorrectServiceImpl implements WindSpeedCorrectService { @Autowired private SysPowerCurveFactorMapper sysPowerCurveFactorMapper; + @Autowired + private CacheService cacheService; + @Override public void importWindSpeedCorrect(MultipartFile file) throws IOException { // 通过文件获取输入流 @@ -90,6 +95,8 @@ public class WindSpeedCorrectServiceImpl implements WindSpeedCorrectService { } //批量插入数据库 sysPowerCurveFactorMapper.insertBatch(listData); + //更新缓存数据 + cacheService.getCalcCache().refreshWindSpeedCoef(); } @Override diff --git a/das/src/main/resources/mapper/SysPowerCurveFactorMapper.xml b/das/src/main/resources/mapper/SysPowerCurveFactorMapper.xml index 4a3c1da9..f8b6af66 100644 --- a/das/src/main/resources/mapper/SysPowerCurveFactorMapper.xml +++ b/das/src/main/resources/mapper/SysPowerCurveFactorMapper.xml @@ -24,7 +24,7 @@ and t.turbine_id = #{info.turbineId} - order by sq.name asc + order by sq.name asc, t.speed_min asc diff --git a/ui/dasadmin/src/assets/dashboard/overview07.png b/ui/dasadmin/src/assets/dashboard/overview07.png new file mode 100644 index 00000000..754d6cde Binary files /dev/null and b/ui/dasadmin/src/assets/dashboard/overview07.png differ diff --git a/ui/dasadmin/src/assets/dashboard/overview08.png b/ui/dasadmin/src/assets/dashboard/overview08.png new file mode 100644 index 00000000..0c0223bf Binary files /dev/null and b/ui/dasadmin/src/assets/dashboard/overview08.png differ diff --git a/ui/dasadmin/src/views/backend/dashboard.vue b/ui/dasadmin/src/views/backend/dashboard.vue index b54cfca2..d2d58e44 100644 --- a/ui/dasadmin/src/views/backend/dashboard.vue +++ b/ui/dasadmin/src/views/backend/dashboard.vue @@ -3,79 +3,114 @@ - +
- -
-
全场平均风速
-
- {{realData.attributeMap.windfarmavgwindspeed}} - m/s -
-
-
-
- -
- -
-
全场实时有功
-
- {{realData.attributeMap.windfarmactivepower}} - kW -
-
-
-
+ + + - -
- -
-
全场实时无功
-
- {{realData.attributeMap.windfarmreactivepower}} - kvar -
-
-
-
+ +
- -
- -
-
日发电量
-
- {{realData.attributeMap.windfarmdayprodenergy}} - kWh +
+ {{realData.attributeMap.windfarmavgwindspeed}} + m/s +
+
平均风速
-
-
-
+ + +
+
+ {{realData.attributeMap.windfarmactivepower}} + kW +
+
实时有功
+
+
+ +
+
+ {{realData.attributeMap.windfarmreactivepower}} + kvar +
+
实时无功
+
+
+ +
- -
- -
-
本月发电量
-
- {{realData.attributeMap.windfarmmonthprodenergy}} - kWh +
+ {{realData.attributeMap.windfarmdayprodenergy}} + 万kWh +
+
日发电量
-
+ + +
+ +
+ {{realData.attributeMap.windfarmmonthprodenergy}} + 万kWh +
+
本月发电量
+
+
+ +
+ +
+ {{realData.attributeMap.windfarmyearprodenergy}} + 万kWh +
+
年发电量
+
+
- -
- -
-
年发电量
-
- {{realData.attributeMap.windfarmyearprodenergy}} - kWh + +
+ + + + + +
+
+ {{realData.attributeMap.turbinecountpowerprod}} + +
+
并网台数
-
+
+ +
+
+ {{realData.attributeMap.turbinecountidle}} + +
+
待机台数
+
+
+ +
+
+ {{realData.attributeMap.turbinecountdisconnected}} + +
+
断联台数
+
+
+ +
+
+ {{realData.attributeMap.turbinecountservice}} + +
+
维护台数
+
+
@@ -125,9 +160,7 @@