|
@@ -18,6 +18,7 @@ import com.bizmatics.service.RtAnalogDataService;
|
|
|
import com.bizmatics.service.SiteDynamicPropertiesService;
|
|
|
import com.bizmatics.service.util.SecurityUtils;
|
|
|
import com.bizmatics.service.vo.RadCountVO;
|
|
|
+import com.bizmatics.service.vo.RealScoreOneVO;
|
|
|
import com.bizmatics.service.vo.RealScoreVO;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
@@ -167,6 +168,84 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
|
|
|
return fillRealScoreData(rtAnalogData,siteDynamicProperties,deviceAttribute);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RealScoreOneVO realScoreOne(String deviceCode) {
|
|
|
+ LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(RtAnalogData::getDeviceName,deviceCode);
|
|
|
+ RtAnalogData rtAnalogData = getOne(queryWrapper);
|
|
|
+ Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在"));
|
|
|
+ //查询设备
|
|
|
+ LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
|
|
|
+ deviceQuery.eq(Device::getDeviceCode,deviceCode);
|
|
|
+ Device device = deviceService.getOne(deviceQuery);
|
|
|
+ Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
|
|
|
+ //查询sd
|
|
|
+ LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
|
|
|
+ sdQuery.eq(SiteDynamicProperties::getSiteId,device.getSiteId());
|
|
|
+ SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
|
|
|
+ Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
|
|
|
+ return fillRealScoreDataOne(rtAnalogData,siteDynamicProperties);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RealScoreOneVO fillRealScoreDataOne(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties){
|
|
|
+ List<Double> checkList = new ArrayList<>();
|
|
|
+ RealScoreOneVO realScoreVo = BeanMapperUtils.map(rtAnalogData, RealScoreOneVO.class);
|
|
|
+
|
|
|
+ checkList.add(realScoreVo.getIa());
|
|
|
+ checkList.add(realScoreVo.getIb());
|
|
|
+ checkList.add(realScoreVo.getIc());
|
|
|
+
|
|
|
+ //电流不平衡
|
|
|
+ realScoreVo.setElBalun(checkBalun(checkList));
|
|
|
+
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(realScoreVo.getUa());
|
|
|
+ checkList.add(realScoreVo.getUb());
|
|
|
+ checkList.add(realScoreVo.getUc());
|
|
|
+ //ABC三相电压占比
|
|
|
+ Double max = checkList.stream().max(Double::compareTo).get();
|
|
|
+ if(max==0.00){
|
|
|
+ realScoreVo.setUaPercentage(0.00);
|
|
|
+ realScoreVo.setUbPercentage(0.00);
|
|
|
+ realScoreVo.setUcPercentage(0.00);
|
|
|
+ }else {
|
|
|
+ realScoreVo.setUaPercentage(Arith.div(realScoreVo.getUa(),(max/100*20+max)*100));
|
|
|
+ realScoreVo.setUbPercentage(Arith.div(realScoreVo.getUb(),(max/100*20+max)*100));
|
|
|
+ realScoreVo.setUcPercentage(Arith.div(realScoreVo.getUc(),(max/100*20+max)*100));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //电压不平衡
|
|
|
+ realScoreVo.setVtBalun(checkBalun(checkList));
|
|
|
+ //当前频率
|
|
|
+ realScoreVo.setF(realScoreVo.getF());
|
|
|
+ //频率偏差
|
|
|
+ if (realScoreVo.getF()==0.00){
|
|
|
+ realScoreVo.setFdeviation(0.00);
|
|
|
+ }else {
|
|
|
+ checkList.clear();
|
|
|
+ checkList.add(50.00);
|
|
|
+ checkList.add(realScoreVo.getF());
|
|
|
+ Double max1 = checkList.stream().max(Double::compareTo).get();
|
|
|
+ Double min1 = checkList.stream().min(Double::compareTo).get();
|
|
|
+ realScoreVo.setFdeviation(Arith.sub(max1,min1)/50*100);
|
|
|
+ }
|
|
|
+ if (realScoreVo.getP()==0.00){
|
|
|
+ realScoreVo.setPpercentage(0.00);
|
|
|
+ }else {
|
|
|
+ realScoreVo.setPpercentage(Arith.div(realScoreVo.getP(),realScoreVo.getP()/100*20+realScoreVo.getP()));
|
|
|
+ }
|
|
|
+ if (realScoreVo.getQ()==0.00){
|
|
|
+ realScoreVo.setQpercentage(0.00);
|
|
|
+ }else {
|
|
|
+ realScoreVo.setQpercentage(Arith.div(realScoreVo.getQ(),realScoreVo.getQ()/100*20+realScoreVo.getQ()));
|
|
|
+ }
|
|
|
+
|
|
|
+ realScoreVo.setVoltageLevel(siteDynamicProperties.getVoltageLevel());
|
|
|
+ return realScoreVo;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 填充实时数据
|
|
|
*/
|