|
|
|
package com.zhonglai.luhui.device.analysis.comm.dto.thingsmodels.specs;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.zhonglai.luhui.device.analysis.comm.dto.thingsmodels.ThingsModelBase;
|
|
|
|
import com.zhonglai.luhui.device.analysis.comm.dto.thingsmodels.ThingsModelDataTypeEnum;
|
|
|
|
import com.zhonglai.luhui.device.analysis.comm.dto.thingsmodels.ThingsModelItemBase;
|
|
|
|
import com.zhonglai.luhui.device.domain.IotThingsModel;
|
|
|
|
import lombok.Data;
|
|
|
|
import org.apache.commons.lang3.EnumUtils;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.RoundingMode;
|
|
...
|
...
|
@@ -79,4 +85,63 @@ public class IntegerModelOutput extends ThingsModelItemBase<Integer> |
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
IotThingsModel thingsModel = JSONObject.parseObject("{\"@type\":\"com.zhonglai.luhui.device.domain.IotThingsModel\",\"ascription\":\"1\",\"create_by\":\"admin\",\"data_type\":\"integer\",\"identifier\":\"turbidity\",\"is_config\":0,\"is_monitor\":0,\"is_save_log\":1,\"is_top\":0,\"model_id\":395,\"model_name\":\"浊度\",\"mqtt_username\":\"6_WP\",\"product_id\":9,\"specs\":\"{\\\"acy\\\":10,\\\"max\\\":999999,\\\"min\\\":0,\\\"step\\\":0.1,\\\"unit\\\":\\\"NTU\\\"}\",\"type\":1}\n", IotThingsModel.class);
|
|
|
|
String data_type = thingsModel.getData_type().toUpperCase();
|
|
|
|
if (!EnumUtils.isValidEnum(ThingsModelDataTypeEnum.class, data_type)) {
|
|
|
|
data_type = ThingsModelDataTypeEnum.STRING.name();
|
|
|
|
}
|
|
|
|
Class<ThingsModelBase> aClass = Enum.valueOf(ThingsModelDataTypeEnum.class, data_type).getaClass();
|
|
|
|
ThingsModelBase thingsModelBase = JSON.parseObject(thingsModel.getSpecs(), aClass);
|
|
|
|
thingsModelBase.conversionThingsModel(thingsModel);
|
|
|
|
|
|
|
|
JSONObject jsData = JSONObject.parseObject("{\n" +
|
|
|
|
" \"id\": 1714026179,\n" +
|
|
|
|
" \"0\": {\n" +
|
|
|
|
" \"rssi\": 18,\n" +
|
|
|
|
" \"at\": 369,\n" +
|
|
|
|
" \"bar\": 107987\n" +
|
|
|
|
" },\n" +
|
|
|
|
" \"10_1\": {\n" +
|
|
|
|
" \"type\": 1,\n" +
|
|
|
|
" \"mode\": 0,\n" +
|
|
|
|
" \"state\": 0,\n" +
|
|
|
|
" \"map\": \"1_1\"\n" +
|
|
|
|
" },\n" +
|
|
|
|
" \"10_2\": {\n" +
|
|
|
|
" \"type\": 1,\n" +
|
|
|
|
" \"mode\": 0,\n" +
|
|
|
|
" \"state\": 0,\n" +
|
|
|
|
" \"map\": \"1_2\"\n" +
|
|
|
|
" },\n" +
|
|
|
|
" \"10_3\": {\n" +
|
|
|
|
" \"type\": 1,\n" +
|
|
|
|
" \"mode\": 0,\n" +
|
|
|
|
" \"state\": 0,\n" +
|
|
|
|
" \"map\": \"1_3\"\n" +
|
|
|
|
" },\n" +
|
|
|
|
" \"10_4\": {\n" +
|
|
|
|
" \"type\": 1,\n" +
|
|
|
|
" \"mode\": 0,\n" +
|
|
|
|
" \"state\": 0,\n" +
|
|
|
|
" \"map\": \"1_4\"\n" +
|
|
|
|
" },\n" +
|
|
|
|
" \"1_3\": {\n" +
|
|
|
|
" \"alarm\": 0,\n" +
|
|
|
|
" \"turbidity\": 69,\n" +
|
|
|
|
" \"wt\": 290\n" +
|
|
|
|
" }\n" +
|
|
|
|
"}", JSONObject.class);
|
|
|
|
thingsModelBase.addValue(jsData.get("turbidity"));
|
|
|
|
|
|
|
|
if (!thingsModelBase.checkValue()) {
|
|
|
|
System.out.println("校验通过");
|
|
|
|
ThingsModelItemBase thingsModelItemBase = (ThingsModelItemBase) thingsModelBase;
|
|
|
|
if(1==thingsModelItemBase.getIs_save_log() )
|
|
|
|
{
|
|
|
|
System.out.println("要记录日志");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|