ソースを参照

强制项目ID必须传

lgy 4 年 前
コミット
309b5f0036

+ 1 - 1
src/main/java/com/persagy/client/GroupNettyClientHandler.java

@@ -170,7 +170,7 @@ public class GroupNettyClientHandler extends ChannelInboundHandlerAdapter {
                     alarmRecordRepository.save(zktAlarmRecordDO);
                     alarmRecordRepository.save(zktAlarmRecordDO);
                 }
                 }
             }
             }
-            NettyMessage response = new NettyMessage();
+            NettyMessage response = new NettyMessage(groupNettyClient.projectId);
             response.setOpCode(3);
             response.setOpCode(3);
             response.setRemark("已经收到消息");
             response.setRemark("已经收到消息");
             channelHandlerContext.write(response.toString());
             channelHandlerContext.write(response.toString());

+ 2 - 4
src/main/java/com/persagy/controller/HelloWorld.java

@@ -17,9 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
-import java.util.ArrayList;
+import java.util.*;
-import java.util.Arrays;
-import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 
 
 @Api(tags = "hello")
 @Api(tags = "hello")
@@ -42,7 +40,7 @@ public class HelloWorld {
 	}
 	}
 	@PostMapping("/testMesage")
 	@PostMapping("/testMesage")
 	public String testMesage(@RequestBody JSONObject jsonObject) throws Exception {
 	public String testMesage(@RequestBody JSONObject jsonObject) throws Exception {
-		NettyMessage nettyMessage = new NettyMessage();
+		NettyMessage nettyMessage = new NettyMessage(groupNettyClient.projectId);
 		nettyMessage.setRemark("连接已经建立;");
 		nettyMessage.setRemark("连接已经建立;");
 		nettyMessage.setOpCode(4);
 		nettyMessage.setOpCode(4);
 		JSONObject content = new JSONObject();
 		JSONObject content = new JSONObject();

+ 0 - 1
src/main/java/com/persagy/entity/NettyMessage.java

@@ -10,7 +10,6 @@ import lombok.Setter;
 import java.util.List;
 import java.util.List;
 
 
 @Data
 @Data
-@NoArgsConstructor
 public class NettyMessage<T> {
 public class NettyMessage<T> {
     /*
     /*
     唯一标识
     唯一标识

+ 1 - 1
src/main/java/com/persagy/service/impl/AlarmHandleServiceImpl.java

@@ -79,7 +79,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
     @Override
     @Override
     public void handleIOTData(String msg) throws SchedulerException, InterruptedException {
     public void handleIOTData(String msg) throws SchedulerException, InterruptedException {
         String[] split = msg.split(";");
         String[] split = msg.split(";");
-        if (split.length < 4) {
+        if (split.length % 4 != 0) {
             return;
             return;
         }
         }
         //返回的信息点个数
         //返回的信息点个数

+ 13 - 0
src/main/java/com/persagy/utils/StringUtil.java

@@ -3,10 +3,13 @@ package com.persagy.utils;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.googlecode.aviator.AviatorEvaluator;
+import com.googlecode.aviator.Expression;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 
 
 import java.lang.reflect.Array;
 import java.lang.reflect.Array;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
@@ -444,4 +447,14 @@ public class StringUtil {
         return isEmpty(obj) ? false : Boolean.valueOf(obj.toString());
         return isEmpty(obj) ? false : Boolean.valueOf(obj.toString());
     }
     }
 
 
+    public static void main(String[] args) {
+        JSONObject paramMap = new JSONObject();
+        paramMap.put("hello",6);
+        paramMap.put("X",6.0);
+        paramMap.put("Y",6.0);
+        String exp = "X < seq.min(seq.list(decimal(1), decimal(2.5), decimal(hello), decimal(3.14)))";
+        Expression expExp = AviatorEvaluator.compile(exp, true);
+        Boolean triggerResult = (Boolean) expExp.execute(paramMap);
+        System.out.println("triggerResult:"+triggerResult);
+    }
 }
 }