Prechádzať zdrojové kódy

增加报警通知接口

zhengqiang 5 rokov pred
rodič
commit
cc5def44a9

+ 1 - 1
src/main/java/com/jpsoft/smart/modules/base/controller/ElectricMeterInfoController.java

@@ -46,7 +46,7 @@ public class ElectricMeterInfoController {
             electricMeterInfo.setDelFlag(false);
             electricMeterInfo.setCreateBy(subject);
             electricMeterInfo.setCreateTime(new Date());
-            
+
             int affectCount = electricMeterInfoService.insert(electricMeterInfo);
 
             if (affectCount > 0) {

+ 3 - 2
src/main/java/com/jpsoft/smart/modules/business/controller/MobileApiController.java

@@ -185,7 +185,8 @@ public class MobileApiController {
 
         DecimalFormat df = new DecimalFormat("#.##");
 
-        if(!totalAmount.equals(amount)){
+        //后续可能改为充钱,支付金额>=单价*数量
+        if(totalAmount.compareTo(amount)>0){
             throw  new Exception("支付金额应为:" + df.format(totalAmount) + "!");
         }
 
@@ -199,7 +200,7 @@ public class MobileApiController {
         record.setChargingStatus("10");//10为未充电 20为充电成功
         record.setRoomId(roomId);
         record.setBuyElectricity(num);
-        record.setBuyAmount(totalAmount);
+        record.setBuyAmount(amount);
         record.setBuyType(buyType); //weipay alipay cash
 
         int affectCount = rechargeRecordService.insert(record);

+ 9 - 7
src/main/java/com/jpsoft/smart/modules/communication/server/codec/MeterDecodeHandler.java

@@ -61,16 +61,18 @@ public class MeterDecodeHandler extends ByteToMessageDecoder {
             }
         }
 
-        while (byteBuf.readableBytes()>0) {
-            if(byteBuf.readUnsignedByte() == METER_END_SYMBOL){
-                endIndex = byteBuf.readerIndex()-1;
-                break;
-            }
-        }
+        // 截止符可能在数据段中重复出现
+//        while (byteBuf.readableBytes()>0) {
+//            if(byteBuf.readUnsignedByte() == METER_END_SYMBOL){
+//                endIndex = byteBuf.readerIndex()-1;
+//                break;
+//            }
+//        }
 
         byteBuf.resetReaderIndex();
 
-        if (endIndex - startIndex + 1 == METER_BASE_LENGTH){
+        //累计接收数据保护完整数据段
+        if (startIndex +  METER_BASE_LENGTH <= byteBuf.readableBytes()){
             log.info("找到完整数据段!");
 
             byte[] buffer = new byte[METER_BASE_LENGTH];