Browse Source

Merge remote-tracking branch 'origin/master'

xiao547607 5 năm trước cách đây
mục cha
commit
d69c37a27f

+ 8 - 8
src/main/java/com/jpsoft/smart/SmartCommunityServerApplication.java

@@ -21,13 +21,13 @@ public class SmartCommunityServerApplication implements CommandLineRunner {
 
 	@Override
 	public void run(String... args) throws Exception {
-		tcpServer.start();
-
-		Runtime.getRuntime().addShutdownHook(new Thread(){
-			@Override
-			public void run() {
-				tcpServer.stop();
-			}
-		});
+//		tcpServer.start();
+//
+//		Runtime.getRuntime().addShutdownHook(new Thread(){
+//			@Override
+//			public void run() {
+//				tcpServer.stop();
+//			}
+//		});
 	}
 }

+ 2 - 3
src/main/java/com/jpsoft/smart/config/WebMvcConfig.java

@@ -53,8 +53,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/wxPay/webPay")
 				.excludePathPatterns("/aliPay/tradePrecreatePay")
 				.excludePathPatterns("/aliPay/payNotify")
-				.excludePathPatterns("/wxPay/payNotify");
-
-
+				.excludePathPatterns("/wxPay/payNotify")
+				.excludePathPatterns("/base/alarmInfo/alarmNotify");
 	}
 }

+ 10 - 0
src/main/java/com/jpsoft/smart/modules/base/controller/AlarmInfoController.java

@@ -7,6 +7,7 @@ import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -23,6 +24,15 @@ public class AlarmInfoController {
     @Autowired
     private AlarmInfoService alarmInfoService;
 
+    @PostMapping("alarmNotify")
+    public MessageResult<String> alarmNotify(String message){
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        logger.info(message);
+
+        return msgResult;
+    }
+
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
     public MessageResult<AlarmInfo> create(){

+ 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

@@ -191,7 +191,8 @@ public class MobileApiController {
 
         DecimalFormat df = new DecimalFormat("#.##");
 
-        if(!totalAmount.equals(amount)){
+        //后续可能改为充钱,支付金额>=单价*数量
+        if(totalAmount.compareTo(amount)>0){
             throw  new Exception("支付金额应为:" + df.format(totalAmount) + "!");
         }
 
@@ -205,7 +206,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];