为风速系数增加缓存
This commit is contained in:
parent
700375a64c
commit
2d9179f0af
11
das/src/main/java/com/das/modules/cache/domain/WindSpeedCoefValue.java
vendored
Normal file
11
das/src/main/java/com/das/modules/cache/domain/WindSpeedCoefValue.java
vendored
Normal file
@ -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;
|
||||||
|
}
|
@ -16,4 +16,6 @@ public interface CacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
IotModelCache getIotModelCache();
|
IotModelCache getIotModelCache();
|
||||||
|
|
||||||
|
CalcCache getCalcCache();
|
||||||
}
|
}
|
||||||
|
8
das/src/main/java/com/das/modules/cache/service/CalcCache.java
vendored
Normal file
8
das/src/main/java/com/das/modules/cache/service/CalcCache.java
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.das.modules.cache.service;
|
||||||
|
|
||||||
|
import com.das.modules.cache.domain.WindSpeedCoefValue;
|
||||||
|
|
||||||
|
public interface CalcCache {
|
||||||
|
WindSpeedCoefValue getWindSpeedCoef(Long deviceId);
|
||||||
|
void putWindSpeedCoef(Long deviceId, WindSpeedCoefValue windSpeedCoefValue);
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.das.modules.cache.service.impl;
|
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.CalcCache;
|
||||||
import com.das.modules.cache.service.EquipmentCache;
|
import com.das.modules.cache.service.EquipmentCache;
|
||||||
import com.das.modules.cache.service.IotModelCache;
|
import com.das.modules.cache.service.IotModelCache;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -15,6 +16,9 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
IotModelCache iotModelCache;
|
IotModelCache iotModelCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CalcCache calcCache;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EquipmentCache getEquipmentCache() {
|
public EquipmentCache getEquipmentCache() {
|
||||||
return equipmentCache;
|
return equipmentCache;
|
||||||
@ -25,5 +29,10 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
return iotModelCache;
|
return iotModelCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CalcCache getCalcCache() {
|
||||||
|
return calcCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
45
das/src/main/java/com/das/modules/cache/service/impl/CalcCacheImpl.java
vendored
Normal file
45
das/src/main/java/com/das/modules/cache/service/impl/CalcCacheImpl.java
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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<Long, WindSpeedCoefValue> windSpeedCoefMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
private void init(){
|
||||||
|
List<SysPowerCurveFactorVo> 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());
|
||||||
|
windSpeedCoefMap.put(sysPowerCurveFactorVo.getTurbineId(), windSpeedCoefValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WindSpeedCoefValue getWindSpeedCoef(Long deviceId) {
|
||||||
|
return windSpeedCoefMap.get(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putWindSpeedCoef(Long deviceId, WindSpeedCoefValue windSpeedCoefValue) {
|
||||||
|
windSpeedCoefMap.put(deviceId, windSpeedCoefValue);
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,8 @@ import com.das.common.utils.BeanCopyUtils;
|
|||||||
import com.das.common.utils.PageDataInfo;
|
import com.das.common.utils.PageDataInfo;
|
||||||
import com.das.common.utils.PageQuery;
|
import com.das.common.utils.PageQuery;
|
||||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
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.entity.SysEquipment;
|
||||||
import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
||||||
import com.das.modules.page.domian.dto.IntervalDto;
|
import com.das.modules.page.domian.dto.IntervalDto;
|
||||||
@ -52,6 +54,9 @@ public class WindSpeedCorrectServiceImpl implements WindSpeedCorrectService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysPowerCurveFactorMapper sysPowerCurveFactorMapper;
|
private SysPowerCurveFactorMapper sysPowerCurveFactorMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CacheService cacheService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importWindSpeedCorrect(MultipartFile file) throws IOException {
|
public void importWindSpeedCorrect(MultipartFile file) throws IOException {
|
||||||
// 通过文件获取输入流
|
// 通过文件获取输入流
|
||||||
@ -90,6 +95,15 @@ public class WindSpeedCorrectServiceImpl implements WindSpeedCorrectService {
|
|||||||
}
|
}
|
||||||
//批量插入数据库
|
//批量插入数据库
|
||||||
sysPowerCurveFactorMapper.insertBatch(listData);
|
sysPowerCurveFactorMapper.insertBatch(listData);
|
||||||
|
//更新缓存数据
|
||||||
|
listData.forEach(sysPowerCurveFactor -> {
|
||||||
|
WindSpeedCoefValue windSpeedCoefValue = new WindSpeedCoefValue();
|
||||||
|
windSpeedCoefValue.setMaxValue(sysPowerCurveFactor.getSpeedMax());
|
||||||
|
windSpeedCoefValue.setMinValue(sysPowerCurveFactor.getSpeedMin());
|
||||||
|
windSpeedCoefValue.setCoef(sysPowerCurveFactor.getFactorK());
|
||||||
|
windSpeedCoefValue.setBase(sysPowerCurveFactor.getFactorB());
|
||||||
|
cacheService.getCalcCache().putWindSpeedCoef(sysPowerCurveFactor.getTurbineId(),windSpeedCoefValue);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user