diff --git a/src/main/java/com/lp/controller/iot/IotSensorInfoController.java b/src/main/java/com/lp/controller/iot/IotSensorInfoController.java index ca6427e..b230850 100644 --- a/src/main/java/com/lp/controller/iot/IotSensorInfoController.java +++ b/src/main/java/com/lp/controller/iot/IotSensorInfoController.java @@ -426,6 +426,7 @@ public class IotSensorInfoController extends BaseController { obj.setMtime(new Date()); resultMap = service.update("IotSensorInfo.update", obj) ; if(isOk(resultMap)){ + obj = ProCacheUtil.getCache(CacheName.SENSORINFO, obj.getId().toString(), obj); IotNodeInfoBO nodeDt = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString()); String port_id = (ObjectUtil.isNotEmpty(nodeDt) && nodeDt.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+obj.getPort_id(); diff --git a/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java b/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java index 04e290a..6d56754 100644 --- a/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java +++ b/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java @@ -193,6 +193,10 @@ public class IotSensorInfoServiceImpl extends BaseServiceImpl implements IotSens String[] fields = {"name","measure_unit_type","iot_sensor_type","devide_code","sensor_device_id","port_id","seq","sdata_degree","formula_up","formula_down","data_type","param_names","sdata","param_config","infos","store_strage"}; List list = ExcelUtil.getExcelInfo(file, IotImportSensorInfoBO.class, 0, 16, fields, 2) ; // 不能重复,并且不能已存在,先判断,然后在开始添加,文件内设备不重复,文件外不能跟已有重复 + List measure_unit_types = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "20", new ProDictionaryInfoBO()).getSub(); + List iot_sensor_types = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "24", new ProDictionaryInfoBO()).getSub(); + List store_strages = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "270", new ProDictionaryInfoBO()).getSub(); + for(IotImportSensorInfoBO obj : list){ if(!obj.validate()){ putStatusCode(resultMap, 10000); @@ -214,12 +218,28 @@ public class IotSensorInfoServiceImpl extends BaseServiceImpl implements IotSens putStatusMsg(resultMap, "传感器:["+obj.getSensor_device_id()+port_id+"]已经存在") ; return resultMap ; } + + if(obj.getData_type().equals("数据属性")){ + if(measure_unit_types.stream().noneMatch(v -> v.getName().equals(obj.getMeasure_unit_type()))){ + putStatusCode(resultMap, 10000); + putStatusMsg(resultMap, "传感器:["+obj.getSensor_device_id()+port_id+"]是数据属性,但是其单位未在数据字典中配置,请联系管理员") ; + return resultMap ; + } + if(iot_sensor_types.stream().noneMatch(v -> v.getName().equals(obj.getIot_sensor_type()))){ + putStatusCode(resultMap, 10000); + putStatusMsg(resultMap, "传感器:["+obj.getSensor_device_id()+port_id+"]是数据属性,但是其传感点类型未在数据字典中配置,请联系管理员") ; + return resultMap ; + } + + } + if(store_strages.stream().noneMatch(v -> v.getName().equals(obj.getStore_strage()))){ + putStatusCode(resultMap, 10000); + putStatusMsg(resultMap, "传感器:["+obj.getSensor_device_id()+port_id+"]是数据属性,但是其储存策略未在数据字典中配置,请联系管理员") ; + return resultMap ; + } } Set sensorSet = new HashSet<>(); - List measure_unit_types = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "20", new ProDictionaryInfoBO()).getSub(); - List iot_sensor_types = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "24", new ProDictionaryInfoBO()).getSub(); - List store_strages = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "270", new ProDictionaryInfoBO()).getSub(); for(IotImportSensorInfoBO obj : list){ String port_id = isXRxasn ? "" : "-" + obj.getPort_id(); if(!sensorSet.contains(obj.getSensor_device_id() + port_id)){ diff --git a/src/main/webapp/file/excel/传感器导入模板.xlsx b/src/main/webapp/file/excel/传感器导入模板.xlsx index caf0982..3514247 100644 Binary files a/src/main/webapp/file/excel/传感器导入模板.xlsx and b/src/main/webapp/file/excel/传感器导入模板.xlsx differ