|
|
|
@ -6,10 +6,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
|
|
import com.xzzn.common.utils.DateUtils;
|
|
|
|
|
import com.xzzn.common.utils.StringUtils;
|
|
|
|
|
import com.xzzn.ems.domain.EmsBatteryData;
|
|
|
|
|
import com.xzzn.ems.domain.EmsMqttMessage;
|
|
|
|
|
import com.xzzn.ems.domain.EmsPcsBranchData;
|
|
|
|
|
import com.xzzn.ems.domain.EmsPcsData;
|
|
|
|
|
import com.xzzn.ems.domain.*;
|
|
|
|
|
import com.xzzn.ems.service.IEmsBatteryDataService;
|
|
|
|
|
import com.xzzn.ems.service.IEmsMqttMessageService;
|
|
|
|
|
import com.xzzn.ems.service.IEmsPcsBranchDataService;
|
|
|
|
@ -150,11 +147,115 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber {
|
|
|
|
|
log.info("====================");
|
|
|
|
|
log.info("BMS data:"+ jsonData);
|
|
|
|
|
//BMS 电池簇
|
|
|
|
|
EmsBatteryCluster data = new EmsBatteryCluster();
|
|
|
|
|
// 设置所有 BigDecimal 类型字段为 ZERO
|
|
|
|
|
data.setChargeableCapacity(BigDecimal.ZERO);
|
|
|
|
|
data.setTotalChargedCapacity(BigDecimal.ZERO);
|
|
|
|
|
data.setDischargeableCapacity(BigDecimal.ZERO);
|
|
|
|
|
data.setTotalDischargedCapacity(BigDecimal.ZERO);
|
|
|
|
|
data.setSoh(BigDecimal.ZERO);
|
|
|
|
|
data.setAverageTemperature(BigDecimal.ZERO);
|
|
|
|
|
data.setInsulationResistance(BigDecimal.ZERO);
|
|
|
|
|
data.setCurrentSoc(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxAllowedChargePower(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxAllowedDischargePower(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxAllowedChargeVoltage(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxAllowedDischargeVoltage(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxAllowedChargeCurrent(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxAllowedDischargeCurrent(BigDecimal.ZERO);
|
|
|
|
|
data.setBatteryPackVoltage(BigDecimal.ZERO);
|
|
|
|
|
data.setBatteryPackCurrent(BigDecimal.ZERO);
|
|
|
|
|
data.setBatteryPackTemp(BigDecimal.ZERO);
|
|
|
|
|
data.setBatteryPackSoc(BigDecimal.ZERO);
|
|
|
|
|
data.setBatteryPackSoh(BigDecimal.ZERO);
|
|
|
|
|
data.setBatteryPackInsulationResistance(BigDecimal.ZERO);
|
|
|
|
|
data.setAvgCellVoltage(BigDecimal.ZERO);
|
|
|
|
|
data.setAvgCellTemp(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxCellVoltage(BigDecimal.ZERO);
|
|
|
|
|
data.setMinCellVoltage(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxCellTemp(BigDecimal.ZERO);
|
|
|
|
|
data.setMinCellTemp(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxCellSoc(BigDecimal.ZERO);
|
|
|
|
|
data.setMinCellSoc(BigDecimal.ZERO);
|
|
|
|
|
data.setMaxCellSoh(BigDecimal.ZERO);
|
|
|
|
|
data.setMinCellSoh(BigDecimal.ZERO);
|
|
|
|
|
data.setTotalChargeEnergy(BigDecimal.ZERO);
|
|
|
|
|
data.setTotalDischargeEnergy(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
|
|
// 其他非 BigDecimal 字段
|
|
|
|
|
data.setWorkStatus("1"); // 或其他默认值
|
|
|
|
|
data.setPcsCommunicationStatus("1");
|
|
|
|
|
data.setEmsCommunicationStatus("1");
|
|
|
|
|
data.setCreateBy("system");
|
|
|
|
|
data.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
data.setUpdateBy("system");
|
|
|
|
|
data.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
data.setSiteId("021_FXX_01");
|
|
|
|
|
data.setDeviceId(deviceId);
|
|
|
|
|
data.setMaxCellVoltageId(Long.parseLong("1"));
|
|
|
|
|
data.setMinCellVoltageId(Long.parseLong("1"));
|
|
|
|
|
data.setMaxCellTempId(Long.parseLong("1"));
|
|
|
|
|
data.setMinCellTempId(Long.parseLong("1"));
|
|
|
|
|
data.setMaxCellSocId(Long.parseLong("1"));
|
|
|
|
|
data.setMinCellSocId(Long.parseLong("1"));
|
|
|
|
|
data.setMaxCellSohId(Long.parseLong("1"));
|
|
|
|
|
data.setMinCellSohId(Long.parseLong("1"));
|
|
|
|
|
|
|
|
|
|
//电池堆
|
|
|
|
|
//BMS 电池簇
|
|
|
|
|
EmsBatteryStack dataStack = new EmsBatteryStack();
|
|
|
|
|
// 设置所有 BigDecimal 类型字段为 ZERO
|
|
|
|
|
dataStack.setChargeableCapacity(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setTotalChargedCapacity(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setDischargeableCapacity(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setTotalDischargedCapacity(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setSoh(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setAverageTemperature(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setInsulationResistance(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setCurrentSoc(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxAllowedChargePower(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxAllowedDischargePower(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxAllowedChargeVoltage(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxAllowedDischargeVoltage(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxAllowedChargeCurrent(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxAllowedDischargeCurrent(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setBatteryPackVoltage(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setBatteryPackCurrent(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setBatteryPackTemp(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setBatteryPackSoc(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setBatteryPackSoh(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setBatteryPackInsulationResistance(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setAvgCellVoltage(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setAvgCellTemp(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxCellVoltage(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMinCellVoltage(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxCellTemp(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMinCellTemp(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxCellSoc(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMinCellSoc(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMaxCellSoh(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setMinCellSoh(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setTotalChargeEnergy(BigDecimal.ZERO);
|
|
|
|
|
dataStack.setTotalDischargeEnergy(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 其他非 BigDecimal 字段
|
|
|
|
|
dataStack.setWorkStatus("1"); // 或其他默认值
|
|
|
|
|
dataStack.setPcsCommunicationStatus("1");
|
|
|
|
|
dataStack.setEmsCommunicationStatus("1");
|
|
|
|
|
dataStack.setCreateBy("system");
|
|
|
|
|
dataStack.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
dataStack.setUpdateBy("system");
|
|
|
|
|
dataStack.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
dataStack.setSiteId("021_FXX_01");
|
|
|
|
|
dataStack.setDeviceId(deviceId);
|
|
|
|
|
dataStack.setMaxCellVoltageId(Long.parseLong("1"));
|
|
|
|
|
dataStack.setMinCellVoltageId(Long.parseLong("1"));
|
|
|
|
|
dataStack.setMaxCellTempId(Long.parseLong("1"));
|
|
|
|
|
dataStack.setMinCellTempId(Long.parseLong("1"));
|
|
|
|
|
dataStack.setMaxCellSocId(Long.parseLong("1"));
|
|
|
|
|
dataStack.setMinCellSocId(Long.parseLong("1"));
|
|
|
|
|
dataStack.setMaxCellSohId(Long.parseLong("1"));
|
|
|
|
|
dataStack.setMinCellSohId(Long.parseLong("1"));
|
|
|
|
|
|
|
|
|
|
//单体电池
|
|
|
|
|
Map<String, Map<String, Object>> records = processData(JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {}));
|
|
|
|
@ -164,25 +265,25 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber {
|
|
|
|
|
String recordId = record.getKey();
|
|
|
|
|
Map<String, Object> fields = record.getValue();
|
|
|
|
|
|
|
|
|
|
EmsBatteryData data = new EmsBatteryData();
|
|
|
|
|
data.setDeviceId(recordId);
|
|
|
|
|
data.setBatteryCellId(recordId);
|
|
|
|
|
data.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC")));
|
|
|
|
|
data.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH")));
|
|
|
|
|
data.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD")));
|
|
|
|
|
data.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY")));
|
|
|
|
|
EmsBatteryData batteryData = new EmsBatteryData();
|
|
|
|
|
batteryData.setDeviceId(recordId);
|
|
|
|
|
batteryData.setBatteryCellId(recordId);
|
|
|
|
|
batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC")));
|
|
|
|
|
batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH")));
|
|
|
|
|
batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD")));
|
|
|
|
|
batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY")));
|
|
|
|
|
|
|
|
|
|
data.setBatteryCluster(deviceId);
|
|
|
|
|
data.setBatteryPack(deviceId);
|
|
|
|
|
batteryData.setBatteryCluster(deviceId);
|
|
|
|
|
batteryData.setBatteryPack(deviceId);
|
|
|
|
|
|
|
|
|
|
// 时间戳
|
|
|
|
|
data.setDataTimestamp(new Date());
|
|
|
|
|
batteryData.setDataTimestamp(new Date());
|
|
|
|
|
|
|
|
|
|
// ID字段
|
|
|
|
|
data.setSiteId(("021"));
|
|
|
|
|
data.setClusterDeviceId(("021"));
|
|
|
|
|
batteryData.setSiteId(("021"));
|
|
|
|
|
batteryData.setClusterDeviceId(("021"));
|
|
|
|
|
|
|
|
|
|
list.add(data);
|
|
|
|
|
list.add(batteryData);
|
|
|
|
|
}
|
|
|
|
|
if (list.size() > 0 ) {
|
|
|
|
|
emsBatteryDataService.insertEmsBatteryDataList(list);
|
|
|
|
@ -249,16 +350,12 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber {
|
|
|
|
|
|
|
|
|
|
pcsData.setDeviceId(deviceId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emsPcsDataService.insertEmsPcsData(pcsData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Map<String, Object>> records = processDataPrefix(JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {}));
|
|
|
|
|
List<EmsPcsBranchData> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
//单体电池
|
|
|
|
|
//PCS支路
|
|
|
|
|
for (Map.Entry<String, Map<String, Object>> record : records.entrySet()) {
|
|
|
|
|
String recordId = record.getKey();
|
|
|
|
|
Map<String, Object> fields = record.getValue();
|
|
|
|
|