|
@@ -57,8 +57,11 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
@Value("${customer.code}")
|
|
|
Integer customerCode ;
|
|
|
|
|
|
- @Value("${device.type.nb.code}")
|
|
|
- Integer deviceTypeNBCode ;
|
|
|
+ @Value("${device.type.nb.tj.code}")
|
|
|
+ Integer deviceTypeNBTjCode ;
|
|
|
+
|
|
|
+ @Value("${device.type.nb.188.code}")
|
|
|
+ Integer deviceTypeNB188Code ;
|
|
|
|
|
|
@Value("${device.type.lora.code}")
|
|
|
Integer deviceTypeLoraCode ;
|
|
@@ -114,10 +117,15 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
waterMeter.setDeviceNo(crmInfo.getNccid());
|
|
|
}
|
|
|
}
|
|
|
- else if(request.getMeterType() == 2){
|
|
|
+ else{
|
|
|
// nb表
|
|
|
waterMeter.setDeviceNo(request.getImei());
|
|
|
- waterMeter.setDeviceTypeId(deviceTypeNBCode);
|
|
|
+ if(request.getMeterType() == 2){
|
|
|
+ waterMeter.setDeviceTypeId(deviceTypeNBTjCode);
|
|
|
+ }
|
|
|
+ else if(request.getMeterType() == 3){
|
|
|
+ waterMeter.setDeviceTypeId(deviceTypeNB188Code);
|
|
|
+ }
|
|
|
// 校验设备是否已经注册
|
|
|
WaterMeter exists = waterMeterMapper.findWaterMeterByDeviceNoAndCustomerList(request.getImei(),customerIds);
|
|
|
if(exists != null){
|
|
@@ -266,16 +274,107 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
buildRtnDataForLora(meterReadRecord,rtnData);
|
|
|
}
|
|
|
else if(meterType == 2){
|
|
|
- // 进行NB数据处理
|
|
|
+ // 进行NB天津协议处理
|
|
|
buildRtnDataForNB(meterReadRecord,rtnData);
|
|
|
}
|
|
|
+ else if(meterType == 3){
|
|
|
+ // 进行NB188协议处理
|
|
|
+ buildRtnDataForNB188(meterReadRecord,rtnData);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param meterReadRecord
|
|
|
+ * @param rtnData
|
|
|
+ */
|
|
|
+ protected void buildRtnDataForNB188(MeterReadRecord meterReadRecord,RtnData rtnData){
|
|
|
+ Map<String, String> lastSendData = meterReadRecord.getLastSendData();
|
|
|
+ // 1:关阀 ,0:其他
|
|
|
+ rtnData.setValve(meterReadRecord.getValveState() == 0 ? "1":"0");
|
|
|
+ String batteryQuantity = lastSendData.get("VolStatus");
|
|
|
+ rtnData.setBatteryVotage(batteryQuantity);
|
|
|
+ // 没有的数据默认填0
|
|
|
+ rtnData.setBaseStationID("0");
|
|
|
+ rtnData.setSignalIntensity(lastSendData.get("CSQ"));
|
|
|
+ List<String> stateList = processWaterMeterStateForNB188(lastSendData);
|
|
|
+ String state = stateList.get(0);
|
|
|
+ rtnData.setECUState(state);
|
|
|
+
|
|
|
+ if(!RtnData.STATE_NORMAL.equals(state)){
|
|
|
+ String warnMessage = stateList.get(1);
|
|
|
+ rtnData.setMessage(warnMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取抄表时间,格式:yyyy-MM-dd
|
|
|
+ Date readTime = meterReadRecord.getReadTime();
|
|
|
+ rtnData.setRXDDate(DateUtil.format(readTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ // 表盘读数,原数据
|
|
|
+ rtnData.setRXDReading(meterReadRecord.getReadData());
|
|
|
+ // 抄表止度,向下取整
|
|
|
+ rtnData.setReading(String.valueOf(
|
|
|
+ ((Double)Math.floor(
|
|
|
+ Double.parseDouble(meterReadRecord.getReadData()))).intValue()));
|
|
|
+ rtnData.setMessage("正常");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 返回数据格式第一位为是否告警,0:正常,1:有告警
|
|
|
+ * 第二位告警信息,多个告警信息拼接一起
|
|
|
+ * {
|
|
|
+ * "CSQ" : "19",
|
|
|
+ * "RemoveStatus" : "0",
|
|
|
+ * "VolStatus" : "0",
|
|
|
+ * "valveState" : "10",
|
|
|
+ * "SNR" : "11",
|
|
|
+ * "ElectronicNo" : "18001201002269",
|
|
|
+ * "TIME" : "20210401012615",
|
|
|
+ * "ForcedStatus" : "0",
|
|
|
+ * "DistrubStatus" : "0",
|
|
|
+ * "currentQuantity" : "0.6"
|
|
|
+ * }
|
|
|
+ * @param data
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ protected List<String> processWaterMeterStateForNB188(Map<String, String> data){
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ // 以下报警信息均,0:正常,1:报警
|
|
|
+ String meterState = "0";
|
|
|
+ StringBuffer waringMessage = new StringBuffer();
|
|
|
+ // 低电告警
|
|
|
+ String lowVoltageWarning = data.get("VolStatus");
|
|
|
+ if(RtnData.ALARM_STATE_ERROR.equals(lowVoltageWarning)){
|
|
|
+ waringMessage.append("低电告警,");
|
|
|
+ meterState = "1";
|
|
|
+ }
|
|
|
+ // 磁干扰告警
|
|
|
+ String magneticInterWarning = data.get("DistrubStatus");
|
|
|
+ if(RtnData.ALARM_STATE_ERROR.equals(magneticInterWarning)){
|
|
|
+ waringMessage.append("磁干扰告警,");
|
|
|
+ meterState = "1";
|
|
|
+ }
|
|
|
+ // 电子模块分离告警
|
|
|
+ String eleModuleWarning = data.get("RemoveStatus");
|
|
|
+ if(RtnData.ALARM_STATE_ERROR.equals(eleModuleWarning)){
|
|
|
+ waringMessage.append("电子模块分离告警,");
|
|
|
+ meterState = "1";
|
|
|
+ }
|
|
|
+ // 阀门异常告警
|
|
|
+ String valveWaring = data.get("valveState");
|
|
|
+ if("11".equals(valveWaring)){
|
|
|
+ waringMessage.append("阀门异常告警,");
|
|
|
+ meterState = "1";
|
|
|
+ }
|
|
|
+ result.add(meterState);
|
|
|
+ String waringString = waringMessage.toString();
|
|
|
+ if(StringUtils.isNotBlank(waringString)){
|
|
|
+ result.add(waringString.substring(0,waringString.length()-1));
|
|
|
+ }
|
|
|
+ return result ;
|
|
|
+ }
|
|
|
protected void buildRtnDataForLora(MeterReadRecord meterReadRecord,RtnData rtnData){
|
|
|
// 获取如下信息:基站ID-->cellID,电池电量,信号强度-->CSQ,阀门状态,水表状态,水表状态信息
|
|
|
Map<String, String> lastSendData = meterReadRecord.getLastSendData();
|
|
|
- String valveState = lastSendData.get("VALVE");
|
|
|
- rtnData.setValve(valveState);
|
|
|
+ // 1:关阀 ,0:其他
|
|
|
+ rtnData.setValve(meterReadRecord.getValveState() == 0 ? "1":"0");
|
|
|
|
|
|
String batteryQuantity = lastSendData.get("VOL");
|
|
|
rtnData.setBatteryVotage(batteryQuantity);
|
|
@@ -339,8 +438,8 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
// 获取如下信息:基站ID-->cellID,电池电量,信号强度-->CSQ,阀门状态,水表状态,水表状态信息
|
|
|
Map<String, String> lastSendData = meterReadRecord.getLastSendData();
|
|
|
|
|
|
- String valveState = lastSendData.get("valveState");
|
|
|
- rtnData.setValve(valveState);
|
|
|
+ // 1:关阀 ,0:其他
|
|
|
+ rtnData.setValve(meterReadRecord.getValveState() == 0 ? "1":"0");
|
|
|
|
|
|
String batteryQuantity = lastSendData.get("batteryQuantity");
|
|
|
rtnData.setBatteryVotage(batteryQuantity);
|
|
@@ -459,7 +558,7 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
// 表类型为Lora时,imei对应为物联网平台电子号;
|
|
|
waterMeter = waterMeterMapper.findWaterMeterByMeterNoAndCustomerList(imei,customerIds);
|
|
|
}
|
|
|
- else if(meterType == 2){
|
|
|
+ else if(meterType == 2 || meterType == 3){
|
|
|
// 表类型为NB时,imei对应为物联网平台设备编号;
|
|
|
waterMeter = waterMeterMapper.findWaterMeterByDeviceNoAndCustomerList(imei,customerIds);
|
|
|
}
|