修改bug
This commit is contained in:
@@ -4,9 +4,12 @@ import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.DevCapacityClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,4 +22,7 @@ public interface DevCapacityFeignClient {
|
||||
@PostMapping("/addList")
|
||||
HttpResult<List<String>> addList(@RequestBody List<CsDevCapacityPO> list);
|
||||
|
||||
@PostMapping("/getDevCapacity")
|
||||
|
||||
HttpResult<Double> getDevCapacity(@RequestParam("id") String id);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,12 @@ public class DevCapacityClientFallbackFactory implements FallbackFactory<DevCapa
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Double> getDevCapacity(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取设备模块容量",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.csdevice.api.DevCapacityFeignClient;
|
||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||
import com.njcn.csharmonic.param.FrequencyStatisticalQueryParam;
|
||||
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
||||
@@ -52,6 +53,8 @@ public class MqttMessageHandler {
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final TemperatureService temperatureService;
|
||||
|
||||
private final DevCapacityFeignClient devCapacityFeignClient;
|
||||
private final DecimalFormat df = new DecimalFormat("#0.000");
|
||||
/**
|
||||
* 实时数据应答
|
||||
@@ -208,6 +211,24 @@ public class MqttMessageHandler {
|
||||
|
||||
}
|
||||
});
|
||||
Double capacity = devCapacityFeignClient.getDevCapacity(devId).getData();
|
||||
//获取输出电流计算负载率
|
||||
List<ThdDataVO> iTolOut = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_RmsI_TolOut(A)")).collect(Collectors.toList());
|
||||
iTolOut.forEach(temp->{
|
||||
ThdDataVO thdDataVO = new ThdDataVO();
|
||||
BeanUtils.copyProperties(temp,thdDataVO);
|
||||
temp.setUnit("%");
|
||||
temp.setStatisticalName("load_Rate");
|
||||
if (capacity<=0){
|
||||
temp.setStatisticalData(3.1415926);
|
||||
}else {
|
||||
double v = temp.getStatisticalData() / capacity;
|
||||
thdDataVO.setStatisticalData(Double.valueOf(df.format(v)));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
List<ThdDataVO> notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
|
||||
|
||||
@@ -224,23 +245,150 @@ public class MqttMessageHandler {
|
||||
publisher.send("/zl/devData/"+devId,topoDataJson,1,false);
|
||||
}
|
||||
|
||||
|
||||
// @MqttSubscribe(value = "/zl/askDvrData/{devId}",qos = 1)
|
||||
// public void responseDvrData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
|
||||
// String topoDataJson =redisUtil.getStringByKey (devId+"DVR");
|
||||
// if(StringUtils.isEmpty(topoDataJson)){
|
||||
// List<ThdDataVO> result = new ArrayList<>();
|
||||
// List<ThdDataVO> tempList = new ArrayList<>();
|
||||
//
|
||||
//
|
||||
// //1.查询DVR配置的指标:DVR配置:9fc1de386b623a1339977e168a23ad97
|
||||
// List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect("9fc1de386b623a1339977e168a23ad97").getData();
|
||||
// data.forEach(temp->{
|
||||
// if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){
|
||||
//
|
||||
// FrequencyStatisticalQueryParam frequencyStatisticalQueryParam = new FrequencyStatisticalQueryParam();
|
||||
// frequencyStatisticalQueryParam.setDevId(devId);
|
||||
// frequencyStatisticalQueryParam.setStatisticalId(temp.getId());
|
||||
// frequencyStatisticalQueryParam.setValueType("avg");
|
||||
// frequencyStatisticalQueryParam.setFrequencyStart(temp.getHarmStart());
|
||||
// frequencyStatisticalQueryParam.setFrequencyEnd(temp.getHarmEnd());
|
||||
// List<ThdDataVO> thdDataVOList = stableDataService.QuerySqlData(frequencyStatisticalQueryParam);
|
||||
// tempList.addAll(thdDataVOList);
|
||||
//
|
||||
// }else {
|
||||
// CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam();
|
||||
// commonStatisticalQueryParam.setDevId(devId);
|
||||
// commonStatisticalQueryParam.setStatisticalId(temp.getId());
|
||||
// commonStatisticalQueryParam.setValueType("avg");
|
||||
// List<ThdDataVO> listFuture= stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
|
||||
// tempList.addAll(listFuture);
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// //过滤M相
|
||||
//// List<ThdDataVO> m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
|
||||
//// m.stream().forEach(temp->{
|
||||
//// Stream.of("A","B","C").forEach(phase->{
|
||||
//// ThdDataVO thdDataVO = new ThdDataVO();
|
||||
//// BeanUtils.copyProperties(temp,thdDataVO);
|
||||
//// thdDataVO.setPhase(phase);
|
||||
//// result.add(thdDataVO);
|
||||
//// });
|
||||
//// });
|
||||
//// //过滤谐波电流,谐波电压畸变率求平均值
|
||||
//// List<ThdDataVO> thdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Pq_ThdU(%)")).collect(Collectors.toList());
|
||||
//// Map<String, List<ThdDataVO>> collect = thdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
|
||||
//// collect.forEach((k,v)->{
|
||||
//// if(!CollectionUtil.isEmpty(v)){
|
||||
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
|
||||
//// ThdDataVO thdDataVO = new ThdDataVO();
|
||||
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
|
||||
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
|
||||
//// thdDataVO.setPhase("avg");
|
||||
//// result.add(thdDataVO);
|
||||
////
|
||||
//// }
|
||||
//// });
|
||||
////
|
||||
//// List<ThdDataVO> thdV = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Pq_ThdI(%)")).collect(Collectors.toList());
|
||||
//// Map<String, List<ThdDataVO>> collect1 = thdV.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
|
||||
//// collect1.forEach((k,v)->{
|
||||
//// if(!CollectionUtil.isEmpty(v)){
|
||||
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
|
||||
//// ThdDataVO thdDataVO = new ThdDataVO();
|
||||
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
|
||||
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
|
||||
//// thdDataVO.setPhase("avg");
|
||||
//// result.add(thdDataVO);
|
||||
////
|
||||
//// }
|
||||
//// });
|
||||
//// List<ThdDataVO> apfThdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Load(%)")).collect(Collectors.toList());
|
||||
//// Map<String, List<ThdDataVO>> collect3 = apfThdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
|
||||
//// collect3.forEach((k,v)->{
|
||||
//// if(!CollectionUtil.isEmpty(v)){
|
||||
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
|
||||
//// ThdDataVO thdDataVO = new ThdDataVO();
|
||||
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
|
||||
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
|
||||
//// thdDataVO.setPhase("avg");
|
||||
//// result.add(thdDataVO);
|
||||
////
|
||||
//// }
|
||||
//// });
|
||||
//// List<ThdDataVO> apfRmsI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_RmsI_TolOut(A)")).collect(Collectors.toList());
|
||||
//// Map<String, List<ThdDataVO>> collect2 = apfRmsI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
|
||||
//// collect2.forEach((k,v)->{
|
||||
//// if(!CollectionUtil.isEmpty(v)){
|
||||
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
|
||||
//// ThdDataVO thdDataVO = new ThdDataVO();
|
||||
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
|
||||
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
|
||||
//// thdDataVO.setPhase("avg");
|
||||
//// result.add(thdDataVO);
|
||||
////
|
||||
//// }
|
||||
//// });
|
||||
//// List<ThdDataVO> apfThdISys = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Sys(%)")).collect(Collectors.toList());
|
||||
//// Map<String, List<ThdDataVO>> collect4 = apfThdISys.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
|
||||
//// collect4.forEach((k,v)->{
|
||||
//// if(!CollectionUtil.isEmpty(v)){
|
||||
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
|
||||
//// ThdDataVO thdDataVO = new ThdDataVO();
|
||||
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
|
||||
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
|
||||
//// thdDataVO.setPhase("avg");
|
||||
//// result.add(thdDataVO);
|
||||
////
|
||||
//// }
|
||||
//// });
|
||||
////
|
||||
//// List<ThdDataVO> notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
|
||||
//
|
||||
// result.addAll(tempList);
|
||||
//
|
||||
//
|
||||
//
|
||||
// Gson gson = new Gson();
|
||||
// topoDataJson = gson.toJson(result);
|
||||
// redisUtil.saveByKeyWithExpire(devId+"DVR", (Object) topoDataJson,Long.valueOf(10*60));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// publisher.send("/zl/DvrData/"+devId,topoDataJson,1,false);
|
||||
// }
|
||||
|
||||
public String getCldidName( String cldid) {
|
||||
|
||||
switch (cldid) {
|
||||
case "0":
|
||||
return "主模块";
|
||||
case "1":
|
||||
return "模块1";
|
||||
return "APF模块 1";
|
||||
case "2":
|
||||
return "模块2";
|
||||
return "APF模块 2";
|
||||
case "3":
|
||||
return "模块3";
|
||||
return "APF模块 3";
|
||||
case "4":
|
||||
return "模块4";
|
||||
return "APF模块 4";
|
||||
case "5":
|
||||
return "模块5";
|
||||
return "APF模块 5";
|
||||
case "6":
|
||||
return "模块6";
|
||||
return "APF模块 6";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user