|
@@ -2,7 +2,9 @@ package com.persagy.simulator_gaopin;
|
|
|
|
|
|
import cn.hutool.core.io.resource.ResourceUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.persagy.simulator.MeterSimulatorWalker;
|
|
@@ -23,7 +25,7 @@ import java.util.*;
|
|
|
@Slf4j
|
|
|
public class Constant {
|
|
|
static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
-
|
|
|
+ public static final List<String> types = Arrays.asList("double","integer","boolean","enum","acc");
|
|
|
public static String socket_or_mqtt = "socket";
|
|
|
|
|
|
public static MqttConnectOptions mqtt_options;
|
|
@@ -354,9 +356,16 @@ public class Constant {
|
|
|
group.funcid = NumberUtil.parseInt(contentList.get(1));
|
|
|
group.data_type = contentList.get(2).toLowerCase();
|
|
|
group.period_second = NumberUtil.parseInt(contentList.get(3));
|
|
|
- if (group.data_type.equals("double")) {
|
|
|
- } else if (group.data_type.equals("integer") || group.data_type.equals("boolean") || group.data_type.equals("enum")|| group.data_type.equals("acc")) {
|
|
|
- } else {
|
|
|
+ if(!types.contains(group.data_type)){
|
|
|
+ log.warn("丢弃一行不合法参数:{}", JSON.toJSONString(group));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(group.period_second<=0){
|
|
|
+ log.warn("丢弃一行不合法参数:{}", JSON.toJSONString(group));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!ObjectUtil.isAllNotEmpty(group.meter,group.funcid)){
|
|
|
+ log.warn("丢弃一行不合法参数:{}", JSON.toJSONString(group));
|
|
|
continue;
|
|
|
}
|
|
|
if (contentList.get(4) != null && contentList.get(4).trim().length() > 0
|