|
@@ -56,9 +56,11 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
@Value("${customer.code}")
|
|
|
Integer customerCode ;
|
|
|
|
|
|
- @Value("${device.type.code}")
|
|
|
- Integer deviceTypeCode ;
|
|
|
+ @Value("${device.type.nb.code}")
|
|
|
+ Integer deviceTypeNBCode ;
|
|
|
|
|
|
+ @Value("${device.type.lora.code}")
|
|
|
+ Integer deviceTypeLoraCode ;
|
|
|
|
|
|
@Autowired
|
|
|
MeterReadRecordRepository meterReadRecordRepository ;
|
|
@@ -92,7 +94,14 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
waterMeter.setMeterNo(request.getRegistNo());
|
|
|
waterMeter.setMeterFileNo(request.getCustomerNo());
|
|
|
waterMeter.setLocation(request.getLocation());
|
|
|
- waterMeter.setDeviceTypeId(deviceTypeCode);
|
|
|
+ if(request.getMeterType() == 1){
|
|
|
+ // Lora表
|
|
|
+ waterMeter.setDeviceTypeId(deviceTypeLoraCode);
|
|
|
+ }
|
|
|
+ else if(request.getMeterType() == 2){
|
|
|
+ // nb表
|
|
|
+ waterMeter.setDeviceTypeId(deviceTypeNBCode);
|
|
|
+ }
|
|
|
waterMeter.setSiteId(community.getSiteId());
|
|
|
waterMeter.setCustomerId(community.getCustomerId());
|
|
|
waterMeter.setProvince(community.getProvince());
|
|
@@ -143,15 +152,22 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
return waterMeterService.saveWaterWaterMeter(waterMeter) ;
|
|
|
}
|
|
|
@Override
|
|
|
- public RespData queryReadRecordData(String[] imeiArray,Integer readDay){
|
|
|
+ public RespData queryReadRecordData(String[] imeiArray,Integer readDay,Integer meterType){
|
|
|
if(readDay == null){
|
|
|
- // 默认查询今天的
|
|
|
- readDay = Integer.parseInt(DateUtil.format(DateUtil.date(),
|
|
|
- Constants.DEFAULT_METER_READ_DATE_FORMAT));
|
|
|
+ // Lora表,默认查询前一天的数据,NB表,默认查询当天的数据
|
|
|
+ if(meterType == 1){
|
|
|
+ readDay = Integer.parseInt(DateUtil.format(DateUtil.offsetDay(DateUtil.date(),-1),
|
|
|
+ Constants.DEFAULT_METER_READ_DATE_FORMAT));
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // 默认查询今天的
|
|
|
+ readDay = Integer.parseInt(DateUtil.format(DateUtil.date(),
|
|
|
+ Constants.DEFAULT_METER_READ_DATE_FORMAT));
|
|
|
+ }
|
|
|
}
|
|
|
RespData respData = new RespData();
|
|
|
List<String> deviceNoList = Arrays.asList(imeiArray);
|
|
|
- List<Integer> customerIds = findCustomerIdsWithChildren(customerCode);
|
|
|
+ //List<Integer> customerIds = findCustomerIdsWithChildren(customerCode);
|
|
|
List<WaterMeter> waterMeterList = waterMeterService.findWaterMeterListWithChildrenCustomer(deviceNoList,
|
|
|
customerCode);
|
|
|
Criteria criteria = Criteria.where("readDate").is(readDay)
|
|
@@ -174,7 +190,7 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
MeterReadRecord meterReadRecord = meterReadRecordMap.get(imei);
|
|
|
rtnData.setECURegDate(DateUtil.format(waterMeter.getDateCreate(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
if(meterReadRecord != null){
|
|
|
- buildRtnData(meterReadRecord,rtnData);
|
|
|
+ buildRtnData(meterReadRecord,rtnData,meterType);
|
|
|
}
|
|
|
else {
|
|
|
rtnData.setECUState(RtnData.STATE_NO_DATA);
|
|
@@ -193,7 +209,88 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
return respData;
|
|
|
}
|
|
|
|
|
|
- protected void buildRtnData(MeterReadRecord meterReadRecord,RtnData rtnData){
|
|
|
+ /**
|
|
|
+ * 构造返回数据
|
|
|
+ * @param meterReadRecord 抄表记录
|
|
|
+ * @param rtnData 返回数据
|
|
|
+ * @param meterType 表类型
|
|
|
+ */
|
|
|
+ protected void buildRtnData(MeterReadRecord meterReadRecord,RtnData rtnData,Integer meterType){
|
|
|
+ if(meterType == 1){
|
|
|
+ // 进行LoRa数据处理
|
|
|
+ buildRtnDataForLora(meterReadRecord,rtnData);
|
|
|
+ }
|
|
|
+ else if(meterType == 2){
|
|
|
+ // 进行NB数据处理
|
|
|
+ buildRtnDataForNB(meterReadRecord,rtnData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void buildRtnDataForLora(MeterReadRecord meterReadRecord,RtnData rtnData){
|
|
|
+ // 获取如下信息:基站ID-->cellID,电池电量,信号强度-->CSQ,阀门状态,水表状态,水表状态信息
|
|
|
+ Map<String, String> lastSendData = meterReadRecord.getLastSendData();
|
|
|
+ String valveState = lastSendData.get("VALVE");
|
|
|
+ rtnData.setValve(valveState);
|
|
|
+
|
|
|
+ String batteryQuantity = lastSendData.get("VOL");
|
|
|
+ rtnData.setBatteryVotage(batteryQuantity);
|
|
|
+ // 没有的数据默认填0
|
|
|
+ rtnData.setBaseStationID("0");
|
|
|
+ rtnData.setSignalIntensity("0");
|
|
|
+
|
|
|
+ List<String> stateList = processWaterMeterStateForLora(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("正常");
|
|
|
+ }
|
|
|
+
|
|
|
+ protected List<String> processWaterMeterStateForLora(Map<String, String> data){
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ // 以下报警信息均,0:正常,1:报警
|
|
|
+ String meterState = "0";
|
|
|
+ StringBuffer waringMessage = new StringBuffer();
|
|
|
+ // 低电告警
|
|
|
+ String lowVoltageWarning = data.get("VOL_STATUS");
|
|
|
+ if(RtnData.ALARM_STATE_ERROR.equals(lowVoltageWarning)){
|
|
|
+ waringMessage.append("低电告警,");
|
|
|
+ meterState = "1";
|
|
|
+ }
|
|
|
+ // 磁干扰告警
|
|
|
+ String magneticInterWarning = data.get("DISTURB");
|
|
|
+ if(RtnData.ALARM_STATE_ERROR.equals(magneticInterWarning)){
|
|
|
+ waringMessage.append("磁干扰告警,");
|
|
|
+ meterState = "1";
|
|
|
+ }
|
|
|
+ // 反流告警
|
|
|
+ String refluxWarningQuantity = data.get("FORCED");
|
|
|
+ if(RtnData.ALARM_STATE_ERROR.equals(refluxWarningQuantity)){
|
|
|
+ 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 buildRtnDataForNB(MeterReadRecord meterReadRecord,RtnData rtnData){
|
|
|
// 获取如下信息:基站ID-->cellID,电池电量,信号强度-->CSQ,阀门状态,水表状态,水表状态信息
|
|
|
Map<String, String> lastSendData = meterReadRecord.getLastSendData();
|
|
|
|
|
@@ -209,7 +306,7 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
String rspr = lastSendData.get("RSPR");
|
|
|
rtnData.setSignalIntensity(rspr);
|
|
|
|
|
|
- List<String> stateList = processWaterMeterState(lastSendData);
|
|
|
+ List<String> stateList = processWaterMeterStateForNB(lastSendData);
|
|
|
String state = stateList.get(0);
|
|
|
rtnData.setECUState(state);
|
|
|
|
|
@@ -235,7 +332,7 @@ public class TianJinMeterReadingServiceImpl implements TianJinMeterReadingServic
|
|
|
* @param data
|
|
|
* @return
|
|
|
*/
|
|
|
- protected List<String> processWaterMeterState(Map<String, String> data){
|
|
|
+ protected List<String> processWaterMeterStateForNB(Map<String, String> data){
|
|
|
List<String> result = new ArrayList<>();
|
|
|
// 以下报警信息均,0:正常,1:报警
|
|
|
String meterState = "0";
|