Commit d39cc74f authored by xieshaojun's avatar xieshaojun

更新代码,协议自定义

parent a3ba6639
package vc.thinker.thirdpartyproxy.protocolimpls.centralAir; package vc.thinker.thirdpartyproxy.protocolimpls.centralAir;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import vc.thinker.absctacts.protocolproxy.enums.IProtocolType; import vc.thinker.absctacts.protocolproxy.enums.IProtocolType;
import vc.thinker.absctacts.protocolproxy.protocol.AbstractThirdPartyProtocol; import vc.thinker.absctacts.protocolproxy.protocol.AbstractThirdPartyProtocol;
import vc.thinker.config.device.DeviceInfoConfig; import vc.thinker.config.device.DeviceInfoConfig;
...@@ -13,7 +11,6 @@ import vc.thinker.mqtt.forwardthinker.ThinkerProdProtocolClient; ...@@ -13,7 +11,6 @@ import vc.thinker.mqtt.forwardthinker.ThinkerProdProtocolClient;
import vc.thinker.mqtt.forwardthinker.dto.ThinkerReportDTO; import vc.thinker.mqtt.forwardthinker.dto.ThinkerReportDTO;
import vc.thinker.thirdpartyproxy.ProtocolType; import vc.thinker.thirdpartyproxy.ProtocolType;
import vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto.DataReportInfoDTO; import vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto.DataReportInfoDTO;
import vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto.DataReportParamDTO;
/** /**
* 中央空调代理上报网关协议 * 中央空调代理上报网关协议
...@@ -47,24 +44,24 @@ public class CentralAirProtocol extends AbstractThirdPartyProtocol implements Te ...@@ -47,24 +44,24 @@ public class CentralAirProtocol extends AbstractThirdPartyProtocol implements Te
ThinkerReportDTO dto = new ThinkerReportDTO(); ThinkerReportDTO dto = new ThinkerReportDTO();
dto.setDeviceCode(deviceInfoConfig.getCode()); dto.setDeviceCode(deviceInfoConfig.getCode());
dto.setTimestamp(dataReportInfoDTO.getTimestamp()); dto.setTimestamp(dataReportInfoDTO.getTimestamp());
JSONObject dataMap = new JSONObject(); // JSONObject dataMap = new JSONObject();
DataReportParamDTO paramDTO = dataReportInfoDTO.getData(); // DataReportParamDTO paramDTO = dataReportInfoDTO.getData();
if (!ObjectUtils.isEmpty(paramDTO.getElectricity())){ // if (!ObjectUtils.isEmpty(paramDTO.getElectricity())){
dataMap.put(CentralAirMeterAttrDefine.electricity.getCode(), dataReportInfoDTO.getData().getElectricity()); // dataMap.put(CentralAirMeterAttrDefine.electricity.getCode(), dataReportInfoDTO.getData().getElectricity());
} // }
if (!ObjectUtils.isEmpty(paramDTO.getColdCapacity())) { // if (!ObjectUtils.isEmpty(paramDTO.getColdCapacity())) {
dataMap.put(CentralAirMeterAttrDefine.coldCapacity.getCode(), dataReportInfoDTO.getData().getColdCapacity()); // dataMap.put(CentralAirMeterAttrDefine.coldCapacity.getCode(), dataReportInfoDTO.getData().getColdCapacity());
} // }
if (!ObjectUtils.isEmpty(paramDTO.getSystemCop())) { // if (!ObjectUtils.isEmpty(paramDTO.getSystemCop())) {
dataMap.put(CentralAirMeterAttrDefine.systemCop.getCode(), dataReportInfoDTO.getData().getSystemCop()); // dataMap.put(CentralAirMeterAttrDefine.systemCop.getCode(), dataReportInfoDTO.getData().getSystemCop());
} // }
if (!ObjectUtils.isEmpty(paramDTO.getSupplyWaterTemp())) { // if (!ObjectUtils.isEmpty(paramDTO.getSupplyWaterTemp())) {
dataMap.put(CentralAirMeterAttrDefine.supplyWaterTemp.getCode(), dataReportInfoDTO.getData().getSupplyWaterTemp()); // dataMap.put(CentralAirMeterAttrDefine.supplyWaterTemp.getCode(), dataReportInfoDTO.getData().getSupplyWaterTemp());
} // }
if (!ObjectUtils.isEmpty(paramDTO.getReturnWaterTemp())) { // if (!ObjectUtils.isEmpty(paramDTO.getReturnWaterTemp())) {
dataMap.put(CentralAirMeterAttrDefine.returnWaterTemp.getCode(), dataReportInfoDTO.getData().getReturnWaterTemp()); // dataMap.put(CentralAirMeterAttrDefine.returnWaterTemp.getCode(), dataReportInfoDTO.getData().getReturnWaterTemp());
} // }
dto.setDatas(dataMap); dto.setDatas(dataReportInfoDTO.getData());
thinkerProdProtocolClient.report(protocolType().getCode(),dto); thinkerProdProtocolClient.report(protocolType().getCode(),dto);
} }
} }
package vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto; package vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -22,6 +23,6 @@ public class DataReportInfoDTO { ...@@ -22,6 +23,6 @@ public class DataReportInfoDTO {
private Long timestamp; private Long timestamp;
@ApiModelProperty("协议数据") @ApiModelProperty("协议数据")
private DataReportParamDTO data; private JSONObject data;
} }
...@@ -54,7 +54,7 @@ public class CentralAirController { ...@@ -54,7 +54,7 @@ public class CentralAirController {
.protocolCode(reportVO.getProtocolCode()) .protocolCode(reportVO.getProtocolCode())
//.deviceAddress(reportVO.getDeviceAddress()) //.deviceAddress(reportVO.getDeviceAddress())
.timestamp(reportVO.getTimestamp()) .timestamp(reportVO.getTimestamp())
.data(JSONObject.parseObject(JSONObject.toJSONString(reportVO.getData()), DataReportParamDTO.class)) .data(reportVO.getData())
.build(); .build();
this.centralAirProtocol.dataReport(dto); this.centralAirProtocol.dataReport(dto);
simpleResponse.setSuccess(true); simpleResponse.setSuccess(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment