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/FunctionAvgValue.java b/das/src/main/java/com/das/modules/calc/functions/FunctionAvgValue.java new file mode 100644 index 00000000..68742ee6 --- /dev/null +++ b/das/src/main/java/com/das/modules/calc/functions/FunctionAvgValue.java @@ -0,0 +1,76 @@ +package com.das.modules.calc.functions; + +import cn.hutool.core.date.DateField; +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.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.Map; + +/** + * Aviator扩展函数 - 获取时间维度内平均 + * 函数格式: avg(deviceId, attr, timedim) + * timedim: day - 天, month - 月, year - 年 + * 返回值:数值, nil - 获取错误 + */ +@Slf4j +public class FunctionAvgValue extends AbstractFunction { + + private DataService dataService = null; + private CacheService cacheService = null; + + + public FunctionAvgValue(DataService dataService, CacheService cacheService) { + this.dataService = dataService; + this.cacheService = cacheService; + } + + @Override + public String getName() { + return "avgv"; + } + + @Override + public AviatorObject call(Map env, AviatorObject deviceCode, AviatorObject attr) { + //设备Code + String code = (String)deviceCode.getValue(env); + String attrName = (String)attr.getValue(env); + + DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code); + if (deviceInfoCache == null) { + return AviatorNil.NIL; + } + Double value = dataService.getTimeAvgValue(deviceInfoCache.getDeviceId(), attrName, null, null); + if (value == null){ + return AviatorNil.NIL; + } + //未找到缓存,查询时序API获取数据 + return AviatorRuntimeJavaType.valueOf(value); + } + @Override + public AviatorObject call(Map env, AviatorObject deviceCode, AviatorObject attr, AviatorObject startTimeData, AviatorObject endTimeData) { + //设备Code + String code = (String)deviceCode.getValue(env); + String attrName = (String)attr.getValue(env); + Date startTime = (Date)startTimeData.getValue(env); + Date endTime = (Date)endTimeData.getValue(env); + DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code); + if (deviceInfoCache == null) { + return AviatorNil.NIL; + } + Double value = dataService.getTimeSumValue(deviceInfoCache.getDeviceId(), attrName, startTime.getTime(), endTime.getTime()); + if (value == null){ + return AviatorNil.NIL; + } + //未找到缓存,查询时序API获取数据 + return AviatorRuntimeJavaType.valueOf(value); + } + +} diff --git a/das/src/main/java/com/das/modules/calc/functions/FunctionOffsetDate.java b/das/src/main/java/com/das/modules/calc/functions/FunctionOffsetDate.java new file mode 100644 index 00000000..67582de4 --- /dev/null +++ b/das/src/main/java/com/das/modules/calc/functions/FunctionOffsetDate.java @@ -0,0 +1,60 @@ +package com.das.modules.calc.functions; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateUtil; +import com.googlecode.aviator.runtime.function.AbstractFunction; +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.Map; + +/** + * Aviator扩展函数 - 获取时间维度的起始时间 + * 函数格式: beginOf(Date, TimeDim) + * + */ +@Slf4j +public class FunctionOffsetDate extends AbstractFunction { + + public FunctionOffsetDate() { + } + + @Override + public String getName() { + return "offsetDate"; + } + + @Override + public AviatorObject call(Map env, AviatorObject dateData, AviatorObject dimData, AviatorObject offsetData) { + Date date = (Date) dateData.getValue(env); + String dim = (String) dimData.getValue(env); + Integer offset = (Integer) offsetData.getValue(env); + + Date result = null; + switch (dim) { + case "day": + result = DateUtil.offset(date, DateField.DAY_OF_MONTH, offset); + break; + case "month": + result = DateUtil.offset(date, DateField.MONTH, offset); + break; + case "year": + result = DateUtil.offset(date, DateField.YEAR, offset); + break; + case "hour": + result = DateUtil.offset(date, DateField.HOUR, offset); + break; + case "minute": + result = DateUtil.offset(date, DateField.MINUTE, offset); + break; + case "second": + result = DateUtil.offset(date, DateField.SECOND, offset); + break; + default: + log.error("不支持的维度: {}", dim); + } + return AviatorRuntimeJavaType.valueOf(result); + } +} 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/calc/service/CalcService.java b/das/src/main/java/com/das/modules/calc/service/CalcService.java index af47fab7..0e291a3b 100644 --- a/das/src/main/java/com/das/modules/calc/service/CalcService.java +++ b/das/src/main/java/com/das/modules/calc/service/CalcService.java @@ -128,6 +128,12 @@ public class CalcService { FunctionEndOfDate endOfDate = new FunctionEndOfDate(); aviator.addFunction(endOfDate); + + FunctionAvgValue avgValue = new FunctionAvgValue(dataService, cacheService); + aviator.addFunction(avgValue); + + FunctionOffsetDate offsetDate = new FunctionOffsetDate(); + aviator.addFunction(offsetDate); } /** diff --git a/das/src/main/java/com/das/modules/data/service/DataService.java b/das/src/main/java/com/das/modules/data/service/DataService.java index cf2a2d96..7628653f 100644 --- a/das/src/main/java/com/das/modules/data/service/DataService.java +++ b/das/src/main/java/com/das/modules/data/service/DataService.java @@ -17,6 +17,8 @@ public interface DataService { void updateCalFieldData(List values); - Double getTimeTopValue(Long devcieId, String attr, Long startTime, Long endTime); - Double getTimeSumValue(Long devcieId, String attr, Long startTime, Long endTime); + Double getTimeTopValue(Long deviceId, String attr, Long startTime, Long endTime); + Double getTimeSumValue(Long deviceId, String attr, Long startTime, Long endTime); + + Double getTimeAvgValue(Long deviceId, String attrName, Long startTime, Long endTime); } diff --git a/das/src/main/java/com/das/modules/data/service/TDEngineService.java b/das/src/main/java/com/das/modules/data/service/TDEngineService.java index be7da2d3..639eb10b 100644 --- a/das/src/main/java/com/das/modules/data/service/TDEngineService.java +++ b/das/src/main/java/com/das/modules/data/service/TDEngineService.java @@ -905,4 +905,52 @@ public class TDEngineService { } return result; } + + public Double getTimeAvgValue(String tableName, String attr, Long startTime, Long endTime) { + StringBuffer sb = new StringBuffer(256); + sb.append("select "); + sb.append("avg("); + sb.append(attr); + sb.append(")"); + sb.append(" from "); + sb.append(tableName); + if (startTime != null && endTime != null) { + sb.append(" where "); + sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime, endTime)); + } + Double result = 0.0; + try (Connection conn = hikariDataSource.getConnection(); + Statement smt = conn.createStatement(); + ResultSet rs = smt.executeQuery(sb.toString())) { + if (rs.next()) { + result = rs.getDouble(1); + } + } catch (Exception e) { + log.error("获取数据异常",e); + } + return result; + } + + public Double getTimeAvgCalcValue(String tableName, String attr, Long startTime, Long endTime) { + StringBuffer sb = new StringBuffer(256); + sb.append("select "); + sb.append("avg(datavalue)"); + sb.append(" from "); + sb.append(tableName); + if (startTime != null && endTime != null) { + sb.append(" where "); + sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime, endTime)); + } + Double result = 0.0; + try (Connection conn = hikariDataSource.getConnection(); + Statement smt = conn.createStatement(); + ResultSet rs = smt.executeQuery(sb.toString())) { + if (rs.next()) { + result = rs.getDouble(1); + } + } catch (Exception e) { + log.error("获取数据异常",e); + } + return result; + } } diff --git a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java index 9e8dac56..2b9995d6 100644 --- a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java +++ b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java @@ -268,8 +268,8 @@ public class DataServiceImpl implements DataService { * @return */ @Override - public Double getTimeTopValue(Long devcieId, String attr, Long startTime, Long endTime){ - DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(devcieId); + public Double getTimeTopValue(Long deviceId, String attr, Long startTime, Long endTime){ + DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId); if (deviceInfoCache == null) { return null; } @@ -285,8 +285,8 @@ public class DataServiceImpl implements DataService { } @Override - public Double getTimeSumValue(Long devcieId, String attr, Long startTime, Long endTime) { - DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(devcieId); + public Double getTimeSumValue(Long deviceId, String attr, Long startTime, Long endTime) { + DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId); if (deviceInfoCache == null) { return null; } @@ -301,4 +301,22 @@ public class DataServiceImpl implements DataService { } return tdEngineService.getTimeSumValue(tableName, attr, startTime, endTime); } + + @Override + public Double getTimeAvgValue(Long deviceId, String attr, Long startTime, Long endTime) { + DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId); + if (deviceInfoCache == null) { + return null; + } + String tableName = ""; + if (cacheService.getIotModelCache().isCalculate(deviceInfoCache.getIotModelId(), attr)){ + tableName = String.format("c_%s_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); + return tdEngineService.getTimeAvgCalcValue(tableName, attr, startTime, endTime); + } else if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){ + tableName = String.format("h_%s", deviceInfoCache.getDeviceId()); + } else if (cacheService.getIotModelCache().isLowSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){ + tableName = String.format("l_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase()); + } + return tdEngineService.getTimeAvgValue(tableName, attr, startTime, endTime); + } } diff --git a/das/src/main/java/com/das/modules/equipment/mapper/SysIotModelMapper.java b/das/src/main/java/com/das/modules/equipment/mapper/SysIotModelMapper.java index a76a6510..71fad7fd 100644 --- a/das/src/main/java/com/das/modules/equipment/mapper/SysIotModelMapper.java +++ b/das/src/main/java/com/das/modules/equipment/mapper/SysIotModelMapper.java @@ -19,7 +19,7 @@ public interface SysIotModelMapper extends BaseMapper { List queryServiceByModelId(Long id); - Long queryIotModelIdByName(String code); + Long queryIotModelIdByCode(String code); List getSysIotModelByType(Integer objectType); diff --git a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java index 86d9d1f3..80b14e14 100644 --- a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java +++ b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java @@ -2,12 +2,14 @@ package com.das.modules.equipment.service.impl; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.das.common.config.SessionUtil; +import com.das.common.constant.EquipmentTypeIds; import com.das.common.exceptions.ServiceException; import com.das.common.utils.BeanCopyUtils; import com.das.common.utils.PageDataInfo; @@ -41,6 +43,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.rmi.ServerException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -249,10 +252,19 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { List delSysEquipmentList = new ArrayList<>(); // 遍历 for (List row : list) { + if (ObjectUtil.isAllNotEmpty(row.get(4),row.get(1),row.get(5))){ + throw new ServerException("请检查必填参数:"+row); + } + if (!Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG) && !Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_WIND_FARM)){ + throw new ServerException("设备类型编码错误"+ row.get(1)); + } SysEquipment field = new SysEquipment(); // 根据编码获取物模型id if (StringUtils.hasText(row.get(2).toString())) { - Long iotModelId = sysIotModelMapper.queryIotModelIdByName(row.get(3).toString()); + Long iotModelId = sysIotModelMapper.queryIotModelIdByCode(row.get(2).toString()); + if (iotModelId == null){ + throw new ServerException("物模型编码错误,错误编码:"+ row.get(2).toString()); + } field.setIotModelId(iotModelId); } if (StringUtils.hasText(row.get(13).toString())) { @@ -263,9 +275,9 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { field.setObjectType(Integer.valueOf(row.get(1).toString())); field.setCode(row.get(4).toString()); field.setName(row.get(5).toString()); - field.setMadeinFactory(row.get(6).toString()); - field.setModel(row.get(7).toString()); - field.setLocation(row.get(8).toString()); + field.setMadeinFactory(ObjectUtil.isEmpty(row.get(6)) ? null : row.get(6).toString()); + field.setModel(ObjectUtil.isEmpty(row.get(7)) ? null : row.get(7).toString()); + field.setLocation(ObjectUtil.isEmpty(row.get(8)) ? null : row.get(8).toString()); if (StringUtils.hasText(row.get(9).toString())) { field.setLongitude(Double.valueOf(row.get(9).toString())); } @@ -276,9 +288,9 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { if (StringUtils.hasText(row.get(11).toString())) { field.setInstallDate(sf.parse(row.get(11).toString())); } - field.setRemarks(row.get(12).toString()); - field.setBelongLine(row.get(17).toString()); - field.setStandard(Integer.valueOf(row.get(18).toString())); + field.setRemarks(ObjectUtil.isEmpty(row.get(12)) ? null : row.get(12).toString()); + field.setBelongLine(ObjectUtil.isEmpty(row.get(17)) ? null : row.get(17).toString()); + field.setStandard(ObjectUtil.isEmpty(row.get(18)) ? null : Integer.valueOf(row.get(18).toString())); if (StringUtils.hasText(row.get(19).toString())) { field.setNominalCapacity(Double.valueOf(row.get(19).toString())); } diff --git a/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java b/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java index 5c13d899..e29915c9 100644 --- a/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java +++ b/das/src/main/java/com/das/modules/node/command/HeartbeatCommand.java @@ -56,13 +56,13 @@ public class HeartbeatCommand implements BaseCommand{ } //判断是不是风机 String keyPLCDeviceStatus = String.format("RT:%d:iturbineoperationmode", deviceId); - String keyDeviceStatus = String.format("RT:%d:commfaultstate"); + String keyCommFaultState = String.format("RT:%d:commfaultstate"); Integer plcDeviceStatus = adminRedisTemplate.get(keyPLCDeviceStatus); if (plcDeviceStatus == null){ - adminRedisTemplate.set(keyDeviceStatus, online ? 1 : 0); + adminRedisTemplate.set(keyCommFaultState, online ? 0 : 1); } else{ - adminRedisTemplate.set(keyDeviceStatus, online && plcDeviceStatus == 1 ? 1 : 0); + adminRedisTemplate.set(keyCommFaultState, online && plcDeviceStatus != 0 ? 0 : 1); } } } diff --git a/das/src/main/java/com/das/modules/page/controller/WindSpeedCorrectController.java b/das/src/main/java/com/das/modules/page/controller/WindSpeedCorrectController.java index 51cf4393..b05a57eb 100644 --- a/das/src/main/java/com/das/modules/page/controller/WindSpeedCorrectController.java +++ b/das/src/main/java/com/das/modules/page/controller/WindSpeedCorrectController.java @@ -23,25 +23,25 @@ import java.text.ParseException; public class WindSpeedCorrectController { @Autowired - private WindSpeedCorrectService sysEquipmentService; + private WindSpeedCorrectService windSpeedCorrectService; /** 导入 */ @PostMapping("/import") public R importWindSpeedCorrect( @RequestParam("file") MultipartFile file) throws IOException, ParseException { - sysEquipmentService.importWindSpeedCorrect( file); + windSpeedCorrectService.importWindSpeedCorrect( file); return R.success("导入成功"); } /** 获取风机风速功率修正系数列表 */ @PostMapping("/getList") public R> getList(@RequestBody SysPowerCurveFactorDto dto) { - PageDataInfo list = sysEquipmentService.getList(dto); + PageDataInfo list = windSpeedCorrectService.getList(dto); return R.success(list); } /** 导出 */ @PostMapping("/export") public void exportWindSpeedCorrect(@RequestBody SysPowerCurveFactorDto dto, HttpServletRequest request, HttpServletResponse response) { - sysEquipmentService.exportWindSpeedCorrect(dto,request, response); + windSpeedCorrectService.exportWindSpeedCorrect(dto,request, response); } 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/SysIotModelMapper.xml b/das/src/main/resources/mapper/SysIotModelMapper.xml index e930c439..271248f8 100644 --- a/das/src/main/resources/mapper/SysIotModelMapper.xml +++ b/das/src/main/resources/mapper/SysIotModelMapper.xml @@ -45,7 +45,7 @@ where sims.iot_model_id = #{id} order by sims.porder asc - select id from sys_iot_model where iot_model_code = #{code} 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/WindBlower/index.vue b/ui/dasadmin/src/views/backend/WindBlower/index.vue index e4e92d28..d270d7b1 100644 --- a/ui/dasadmin/src/views/backend/WindBlower/index.vue +++ b/ui/dasadmin/src/views/backend/WindBlower/index.vue @@ -327,7 +327,7 @@ import { useRoute, useRouter } from 'vue-router' import Overview from './overview.vue' import { TableInstance } from 'element-plus' import { dayjs, ElMessage, ElMessageBox } from 'element-plus' -import { getRealTimeState, getCutDecimalsValue } from '/@/views/backend/equipment/airBlower/utils' +import { getRealTimeState, getCutDecimalsValue, malFunctionKeys } from '/@/views/backend/equipment/airBlower/utils' import { sendCommandReq, sendManualCommandReq } from '/@/api/backend/control/request' import { getAlarmListReq } from '/@/api/backend/alarms/request' import { queryfaultCodeDict } from '/@/api/backend/theoreticalpowerCurve/request' @@ -1037,7 +1037,7 @@ const createRealTimeData = async () => { val = enumStore.data[item.attributeCode][val] } if (malFunctionKeys.includes(item.attributeCode)) { - val = malFunctionEnums?.[item.attributeCode] ?? val + val = malFunctionEnums?.[val] ?? val } if (sigleDataKeys.includes(item.attributeCode.toLowerCase())) { realTimeDataForSingle.value[item.attributeCode.toLowerCase()] = val === '-' ? val : val @@ -1345,29 +1345,16 @@ const getAlarmList = () => { }) } -const malFunctionKeys = [ - 'ActiveStatusCode01', - 'ActiveStatusCode02', - 'ActiveStatusCode03', - 'ActiveStatusCode04', - 'ActiveStatusCode05', - 'ActiveStatusCode06', - 'ActiveStatusCode07', - 'ActiveStatusCode08', - 'FirstTriggeredCode', -] - -const malFunctionEnums: any = {} +let malFunctionEnums: any = {} const getMalfunctionEnums = () => { const curWindBlower = airBlowerList.value.find((item) => item.irn === route.query.irn) - console.log(curWindBlower) - queryfaultCodeDict({ madeinfactory: curWindBlower!.madeinfactory, model: curWindBlower!.model }).then((res) => { if (res.code == 200) { const data: any = {} res.data.forEach((item: any) => { data[item.code] = item.description }) + malFunctionEnums = data } }) } diff --git a/ui/dasadmin/src/views/backend/dashboard.vue b/ui/dasadmin/src/views/backend/dashboard.vue index b73c4296..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 @@