diff --git a/src/main/java/com/lp/bo/IotImportSensorInfoBO.java b/src/main/java/com/lp/bo/IotImportSensorInfoBO.java new file mode 100644 index 0000000..73f10e9 --- /dev/null +++ b/src/main/java/com/lp/bo/IotImportSensorInfoBO.java @@ -0,0 +1,50 @@ +package com.lp.bo; + +import com.lp.util.ObjectUtil; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *@类:IotNodeInfo + *@作者:chenrj + */ + +@Data +@NoArgsConstructor +public class IotImportSensorInfoBO { + + private String name; + private String measure_unit_type; + private String iot_sensor_type; + private String iot_sensor_category; + private String devide_code; + private String sensor_device_id; + private String port_id; + private String seq; + private String delete_flag; + private String iot_sensor_status; + private String sdata_degree; + private String formula_up; + private String formula_down; + private String data_type; + private String param_type; + private String param_names; + private String sdata; + private String param_config; + private String infos; + private String store_strage; + + public boolean validate(){ + return ObjectUtil.isNotEmpty(name) + && ObjectUtil.isNotEmpty(devide_code) + && ObjectUtil.isNotEmpty(sensor_device_id) + && ObjectUtil.isNotEmpty(port_id) + && ObjectUtil.isNotEmpty(sdata_degree) + && ObjectUtil.isNotEmpty(data_type) + && ObjectUtil.isNotEmpty(store_strage) + && ((data_type.equals("数据属性") && ObjectUtil.isNotEmpty(measure_unit_type) && ObjectUtil.isNotEmpty(iot_sensor_type)) + || ((data_type.equals("配置属性") && ObjectUtil.isNotEmpty(sdata) && ObjectUtil.isNotEmpty(param_names)))) + ; + } + } + diff --git a/src/main/java/com/lp/common/RequestURLIOT.java b/src/main/java/com/lp/common/RequestURLIOT.java index 0e77897..090d230 100644 --- a/src/main/java/com/lp/common/RequestURLIOT.java +++ b/src/main/java/com/lp/common/RequestURLIOT.java @@ -59,6 +59,7 @@ public class RequestURLIOT { public class SensorInfo { public final static String SENSOR_INFO = "/sensor"; + public final static String SENSOR_INFOS = "/sensors"; public final static String SENSOR_INFO_PAGE = "/page/sensor"; @@ -89,6 +90,8 @@ public class RequestURLIOT { public final static String NODE_REALTIME_VALUE = "/node/realtime/data" ; public final static String SENSOR_REALTIME_CONTROL = "/sensor/realtime/control" ; + + public final static String SENSOR_UPLOAD = "/sensor/upload" ; } public class SensorHistoryInfo { diff --git a/src/main/java/com/lp/controller/iot/IotSceneInfoController.java b/src/main/java/com/lp/controller/iot/IotSceneInfoController.java index c1b2b7c..9fa21fd 100644 --- a/src/main/java/com/lp/controller/iot/IotSceneInfoController.java +++ b/src/main/java/com/lp/controller/iot/IotSceneInfoController.java @@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletResponse; +import java.util.List; import java.util.Map; @@ -139,7 +140,8 @@ public class IotSceneInfoController extends BaseController { // 添加场景缓存 ProCacheUtil.addCache(CacheName.SCENEINFO, obj.getId().toString(), obj); } - } + int ret = iotSceneInfoservice.insertSceneUserRelationForSupper(obj.getId()); + } }else{ putStatusCode(resultMap, Code.ResponseCode.SystemCode.NO_AUTHORIZATION); } diff --git a/src/main/java/com/lp/controller/iot/IotSceneUserRelationController.java b/src/main/java/com/lp/controller/iot/IotSceneUserRelationController.java index f7f241d..2e47b76 100644 --- a/src/main/java/com/lp/controller/iot/IotSceneUserRelationController.java +++ b/src/main/java/com/lp/controller/iot/IotSceneUserRelationController.java @@ -39,7 +39,7 @@ public class IotSceneUserRelationController extends BaseController { @RequestParam Integer paged ) { Map resultMap = getResultMap(); try { - + resultMap = service.selectPageList("IotSceneUserRelation.selectPage",getPageBean(paged,pageSize), obj); } catch (Exception e) { diff --git a/src/main/java/com/lp/controller/iot/IotSensorInfoController.java b/src/main/java/com/lp/controller/iot/IotSensorInfoController.java index e1c7ff3..cca570a 100644 --- a/src/main/java/com/lp/controller/iot/IotSensorInfoController.java +++ b/src/main/java/com/lp/controller/iot/IotSensorInfoController.java @@ -25,6 +25,7 @@ import com.lp.util.iot.ProtocolUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletResponse; @@ -253,6 +254,7 @@ public class IotSensorInfoController extends BaseController { if( ProtocolUtil.sendControlSensorCommand(obj) >-1){ resultMap = service.update("IotSensorInfo.update", tmp) ; }else{ + LogUtil4j.debugLogger.warn("sendControlSensorCommand failed, will offline device {}", obj.getId()); putStatusCode(resultMap, CodeIot.DEVICE_STATUS.OFFLINE); } }else{ @@ -320,6 +322,7 @@ public class IotSensorInfoController extends BaseController { if( ProtocolUtil.sendSensorParamDown(obj) >-1){ ProCacheUtil.addCache(CacheName.SENSOR_PARAM_SETTING, obj.getId()+"", tmp ); }else{ + LogUtil4j.debugLogger.warn("sendSensorParamDown failed, will offline device {}", obj.getId()); putStatusCode(resultMap, CodeIot.DEVICE_STATUS.OFFLINE); } }else{ @@ -348,6 +351,7 @@ public class IotSensorInfoController extends BaseController { if( ProtocolUtil.sendSensorParamRead(obj) >-1){ }else{ + LogUtil4j.debugLogger.warn("sendSensorParamRead failed, will offline device {}", obj.getId()); putStatusCode(resultMap, CodeIot.DEVICE_STATUS.OFFLINE); } }else{ @@ -525,6 +529,7 @@ public class IotSensorInfoController extends BaseController { if( ProtocolUtil.sendControlSensorCommand(tmp) >-1){ resultMap = service.update("IotSensorInfo.update", tmp) ; }else{ + LogUtil4j.debugLogger.warn("sendControlSensorCommand failed, will offline device {}", obj.getId()); putStatusCode(resultMap, CodeIot.DEVICE_STATUS.OFFLINE); } }else{ @@ -540,5 +545,55 @@ public class IotSensorInfoController extends BaseController { } return getModelAndView(response, resultMap); } - + + /** + * 设备excel导入 + */ + @RequestMapping(method = RequestMethod.POST, value = RequestURLIOT.SensorInfo.SENSOR_UPLOAD) + public ModelAndView upload(HttpServletResponse response, + @RequestParam(required = false,value="nodeId") String node_id, + @RequestParam(required = false,value="property") String[] property, + @RequestParam(required = false, value = "file") MultipartFile file) { + Map resultMap = getResultMap(); + try { + resultMap = iotSensorInfoService.importTemplateSensorInfo(file, node_id); + } catch (Exception e) { + super.exception(e, resultMap, file); + } + return getModelAndView(response, resultMap); + } + + + /** + * 批量删除 + * @param response + * @param id + * @return + */ + @RequestMapping(method = RequestMethod.DELETE, value = RequestURLIOT.SensorInfo.SENSOR_INFOS) + public ModelAndView deletes(HttpServletResponse response, + @RequestHeader(value = ResultMapUtils.USER_KEY, required = true) String userKey , + @RequestParam Integer id ) { + Map resultMap = getResultMap(); + try { + IotSensorInfoBO obj = new IotSensorInfoBO(); + if(ObjectUtil.isEmpty(id)){ + putStatusCode(resultMap, Code.ResponseCode.SystemCode.PARAM_ERROR); + }else{ +// obj.setId(id); + obj.setNode_id(id); + obj.setDelete_flag(Constants.DELETE.YES); + obj.setMtime(new Date()); + resultMap = service.update("IotSensorInfo.update", obj) ; + if(isOk(resultMap)){ + ProCacheUtil.removeCache(CacheName.SENSORINFO, obj.getId().toString()); + ProCacheUtil.removeCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id()); + } + } + } catch (Exception e) { + exception(e,resultMap, id); + } + return getModelAndView(response, resultMap); + } + } diff --git a/src/main/java/com/lp/dao/impl/BaseDaoImpl.java b/src/main/java/com/lp/dao/impl/BaseDaoImpl.java index b16c9da..041fdc3 100644 --- a/src/main/java/com/lp/dao/impl/BaseDaoImpl.java +++ b/src/main/java/com/lp/dao/impl/BaseDaoImpl.java @@ -185,7 +185,6 @@ public class BaseDaoImpl extends ResultMapUtils implements BaseDao { } String code_value =null ; try{ - LogUtil4j.debugLogger.debug("dictionaryValue with {}---{}", valueSdata, value); code_value = ObjectUtil.dictionaryValue( Double.parseDouble(String.valueOf(valueSdata)), value); annotationedFieldMap.put(f.getField().getName(), code_value); }catch(NumberFormatException e){ diff --git a/src/main/java/com/lp/mqtt/MessageCallback.java b/src/main/java/com/lp/mqtt/MessageCallback.java index 1da1cbf..cd0f92a 100644 --- a/src/main/java/com/lp/mqtt/MessageCallback.java +++ b/src/main/java/com/lp/mqtt/MessageCallback.java @@ -42,7 +42,7 @@ public class MessageCallback implements MqttCallbackExtended { try{ Thread.sleep(50); // 消息放入线程池中处理 - taskExecutor.execute(new MessageHandler(message.getPayload() , + taskExecutor.execute(new MessageHandler(message.getPayload() , new String(message.getPayload()), topic)); }catch(Exception e){ LOGGER.error("messageArrived error: ", e); diff --git a/src/main/java/com/lp/mqtt/MqttService.java b/src/main/java/com/lp/mqtt/MqttService.java index b3a4de7..00119bf 100644 --- a/src/main/java/com/lp/mqtt/MqttService.java +++ b/src/main/java/com/lp/mqtt/MqttService.java @@ -131,7 +131,7 @@ public class MqttService { */ public static void pubMessage(String message,String topic){ MqttMessage mess = new MqttMessage(); - mess.setQos(1); + mess.setQos(0); mess.setRetained(false); mess.setPayload(message.getBytes()); try { diff --git a/src/main/java/com/lp/service/IotSceneInfoService.java b/src/main/java/com/lp/service/IotSceneInfoService.java index ded5c99..171f290 100644 --- a/src/main/java/com/lp/service/IotSceneInfoService.java +++ b/src/main/java/com/lp/service/IotSceneInfoService.java @@ -12,5 +12,7 @@ public interface IotSceneInfoService { * @return */ Map getSceneDetailInfo(IotSceneInfoBO tmp); - + + int insertSceneUserRelationForSupper(Integer id); + } diff --git a/src/main/java/com/lp/service/IotSensorInfoService.java b/src/main/java/com/lp/service/IotSensorInfoService.java index 9cde54f..f1e4f28 100644 --- a/src/main/java/com/lp/service/IotSensorInfoService.java +++ b/src/main/java/com/lp/service/IotSensorInfoService.java @@ -3,9 +3,11 @@ package com.lp.service; import java.util.Map; import com.lp.bo.IotSensorInfoBO; +import org.springframework.web.multipart.MultipartFile; public interface IotSensorInfoService { Map updateRealTimeData(IotSensorInfoBO tmp); + Map importTemplateSensorInfo(MultipartFile file, String node_id); } diff --git a/src/main/java/com/lp/service/impl/IotSceneServiceImpl.java b/src/main/java/com/lp/service/impl/IotSceneServiceImpl.java index 257fe3a..ccdf090 100644 --- a/src/main/java/com/lp/service/impl/IotSceneServiceImpl.java +++ b/src/main/java/com/lp/service/impl/IotSceneServiceImpl.java @@ -1,7 +1,10 @@ package com.lp.service.impl; +import java.util.List; import java.util.Map; +import com.lp.bo.IotSceneUserRelationBO; +import com.lp.bo.UserInfoBO; import org.springframework.stereotype.Service; import com.lp.bo.IotSceneInfoBO; @@ -27,4 +30,23 @@ public class IotSceneServiceImpl extends BaseServiceImpl implements IotSceneInfo return resultMap; } + @Override + public int insertSceneUserRelationForSupper(Integer id) { + int ret = 0; + UserInfoBO userInfoBO = new UserInfoBO(); + userInfoBO.setType(10); + List list = dao.selectList("UserInfo.selects", userInfoBO); + for(UserInfoBO obj : list){ + IotSceneUserRelationBO tmp = new IotSceneUserRelationBO(); + tmp.setScene_id(id); + tmp.setUser_id(obj.getId()); + tmp.setAid(obj.getId()); + ret = dao.insert("IotSceneUserRelation.insert", tmp); + if(ret <= 0){ + return ret; + } + } + return 0; + } + } diff --git a/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java b/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java index 7ac962c..3cbc8cf 100644 --- a/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java +++ b/src/main/java/com/lp/service/impl/IotSensorInfoServiceImpl.java @@ -1,26 +1,22 @@ package com.lp.service.impl; import com.lp.bean.IotHistorySensorData; -import com.lp.bo.IotNodeInfoBO; -import com.lp.bo.IotSceneInfoBO; -import com.lp.bo.IotSensorInfoBO; +import com.lp.bean.ProDictionaryInfo; +import com.lp.bo.*; import com.lp.cache.CacheName; import com.lp.cache.ProCacheUtil; import com.lp.common.Code; import com.lp.common.CodeIot; import com.lp.service.IotSensorInfoService; -import com.lp.util.Calculator; -import com.lp.util.DateUtils; -import com.lp.util.LogUtil4j; -import com.lp.util.ObjectUtil; +import com.lp.util.*; import com.lp.util.iot.IotTrigger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import java.math.BigDecimal; -import java.util.Date; -import java.util.Map; +import java.util.*; @Service public class IotSensorInfoServiceImpl extends BaseServiceImpl implements IotSensorInfoService { @@ -34,6 +30,7 @@ public class IotSensorInfoServiceImpl extends BaseServiceImpl implements IotSens public Map updateRealTimeData(IotSensorInfoBO obj) { // LogUtil4j.debugLogger.debug("updateRealTimeData is called with ({}---{}---{})" // , obj.getDevice_code() + "-" + obj.getSensor_device_id(), obj.getPort_id(), obj.getRequest_sdata()); + String port_id = ObjectUtil.isEmpty(obj.getPort_id()) ? "" : "-" + obj.getPort_id(); Map resultMap = getResultMap(); try{ // 通过网关缓存 deviceCode -> nodeInfo -> id (or nodeId) @@ -70,7 +67,7 @@ public class IotSensorInfoServiceImpl extends BaseServiceImpl implements IotSens obj.setNode_id( iotNodeInfo.getId() ); // LogUtil4j.debugLogger.debug("get sensorinfo with key: {}", obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id()); // 获取传感器缓存信息 - String port_id = ObjectUtil.isEmpty(obj.getPort_id()) ? "" : "-" + obj.getPort_id(); + IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+port_id, obj); if( ObjectUtil.isEmpty(sensorInfo) ){ @@ -172,13 +169,121 @@ public class IotSensorInfoServiceImpl extends BaseServiceImpl implements IotSens } } }catch(Exception e){ - LOGGER.error("updateRealTimeData wrong!!!", e); + LOGGER.error("updateRealTimeData wrong with ({})!!!", obj.getDevice_code() + "-" + obj.getSensor_device_id() + port_id, e); super.exception(e, obj); putStatusCode(resultMap, Code.ResponseCode.SystemCode.ERROR); } return resultMap; } - + + @Override + public Map importTemplateSensorInfo(MultipartFile file, String node_id) { + Map resultMap = getResultMap(); + try{ + IotNodeInfoBO nodeInfo = ProCacheUtil.getCache(CacheName.NODEINFO, node_id); + if(ObjectUtil.isEmpty(nodeInfo)){ + putStatusCode(resultMap, 10000); + putStatusMsg(resultMap, "设备网关:["+node_id+"]不存在") ; + return resultMap ; + } + boolean isXRxasn = nodeInfo.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn"); + + + + 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) ; + // 不能重复,并且不能已存在,先判断,然后在开始添加,文件内设备不重复,文件外不能跟已有重复 + for(IotImportSensorInfoBO obj : list){ + if(!obj.validate()){ + putStatusCode(resultMap, 10000); + putStatusMsg(resultMap, "传感中关键字段缺失或者存在空行") ; + return resultMap ; + } + if(!isXRxasn){ + if(ObjectUtil.isEmpty(obj.getPort_id())){ + putStatusCode(resultMap, 10000); + putStatusMsg(resultMap, "传感中未填充寄存器号") ; + return resultMap ; + } + } + String port_id = isXRxasn ? "" : "-" + obj.getPort_id(); + IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP, nodeInfo.getId()+"-"+ + obj.getSensor_device_id()+port_id); + if(ObjectUtil.isNotEmpty(sensorInfo)){ + 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)){ + sensorSet.add(obj.getSensor_device_id() + port_id); + IotSensorInfoBO sensorInfo = new IotSensorInfoBO(); + sensorInfo.setName(obj.getName()); + sensorInfo.setSensor_device_id(obj.getSensor_device_id()); + sensorInfo.setDevice_code(obj.getDevide_code()); + sensorInfo.setNode_id(Integer.valueOf(node_id)); + sensorInfo.setSensor_device_id(obj.getSensor_device_id()); + sensorInfo.setPort_id(Integer.valueOf(obj.getPort_id())); + sensorInfo.setData_type(obj.getData_type().equals("数据属性") ? 0 : 1); + sensorInfo.setSdata_degree(Integer.valueOf(obj.getSdata_degree())); + sensorInfo.setStore_strage(store_strages.stream().filter(v -> v.getName().equals(obj.getStore_strage())).findAny().get().getCode()); + if(ObjectUtil.isNotEmpty(obj.getMeasure_unit_type())){ + sensorInfo.setMeasure_unit_type(measure_unit_types.stream().filter(v -> v.getName().equals(obj.getMeasure_unit_type())).findAny().get().getCode()); + } + if(ObjectUtil.isNotEmpty(obj.getIot_sensor_type())) { + sensorInfo.setIot_sensor_type(iot_sensor_types.stream().filter(v -> v.getName().equals(obj.getIot_sensor_type())).findAny().get().getCode()); + } + if(ObjectUtil.isNotEmpty(obj.getSeq())) { + sensorInfo.setSeq(Integer.valueOf(obj.getSeq())); + } + if(ObjectUtil.isNotEmpty(obj.getFormula_up())) { + sensorInfo.setFormula_up(obj.getFormula_up()); + } + if(ObjectUtil.isNotEmpty(obj.getFormula_down())) { + sensorInfo.setFormula_down(obj.getFormula_down()); + } + if(ObjectUtil.isNotEmpty(obj.getSdata())) { + sensorInfo.setSdata(Float.valueOf(obj.getSdata())); + } + if(ObjectUtil.isNotEmpty(obj.getParam_names())) { + sensorInfo.setParam_names(obj.getParam_names()); + } + sensorInfo.setParam_config(ObjectUtil.isNotEmpty(obj.getParam_config()) ? obj.getParam_config() : ""); + sensorInfo.setMtime(new Date()); + sensorInfo.setRegister_time(new Date()); + sensorInfo.setDelete_flag(0); + sensorInfo.setIot_sensor_status(CodeIot.DEVICE_STATUS.OFFLINE); + sensorInfo.setRequest_sdata(0f); + sensorInfo.setStr_sdata(""); + sensorInfo.setInfos(""); + // 保存信息 + int re = dao.insert("IotSensorInfo.insert", sensorInfo) ; + if(re>0){ + ; + ProCacheUtil.addCache(CacheName.SENSORINFO, sensorInfo.getId().toString(), sensorInfo); + ProCacheUtil.addCache(CacheName.SENSORINFO_NSP, sensorInfo.getNode_id()+"-"+ + sensorInfo.getSensor_device_id()+port_id, sensorInfo); + } + }else{ + continue ; + } + } + + }catch (Exception e) { + super.exception(e, null); + putStatusCode(resultMap, Code.ResponseCode.SystemCode.ERROR); + } + putStatusCode(resultMap, Code.ResponseCode.SystemCode.OK); + return resultMap; + } + private Boolean sensorDataStratety(Object oldvalue , Object newValue ,IotSensorInfoBO sensor ){ if( ObjectUtil.isEmpty(sensor.getStoreTime() ) ){ diff --git a/src/main/java/com/lp/util/ExcelUtil.java b/src/main/java/com/lp/util/ExcelUtil.java index 95f18dc..6f7af26 100644 --- a/src/main/java/com/lp/util/ExcelUtil.java +++ b/src/main/java/com/lp/util/ExcelUtil.java @@ -160,7 +160,10 @@ public class ExcelUtil { for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNum++) { Cell cell = row.getCell(cellNum); Object value = null; - if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { + if (ObjectUtil.isEmpty(cell)){ +// 如果该单元格为空,则置为null + ; + } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { Double v = new Double(cell.getNumericCellValue()); if (fieldsTypes[cellNum].getSimpleName().equals("Long")) { value = v.longValue(); diff --git a/src/main/java/com/lp/util/LogUtil.java b/src/main/java/com/lp/util/LogUtil.java index 97b4d4a..321c201 100644 --- a/src/main/java/com/lp/util/LogUtil.java +++ b/src/main/java/com/lp/util/LogUtil.java @@ -6,6 +6,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.log4j.Logger; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.management.ManagementFactory; @@ -18,7 +19,7 @@ public class LogUtil{ public static Logger otherLogger =Logger.getLogger("other"); private final static Log LOGGER = LogFactory.getLog(LogUtil.class); - + private static RuntimeMXBean runtimeMXBean=ManagementFactory.getRuntimeMXBean(); public static void errorLog(Exception e ){ diff --git a/src/main/java/com/lp/util/LogUtil4j.java b/src/main/java/com/lp/util/LogUtil4j.java index 0733fe9..730826b 100644 --- a/src/main/java/com/lp/util/LogUtil4j.java +++ b/src/main/java/com/lp/util/LogUtil4j.java @@ -19,7 +19,7 @@ public class LogUtil4j { // public static Log otherLogger = LogFactory.getLog("other"); public static Logger otherLogger = LoggerFactory.getLogger("other"); public static Logger debugLogger = LoggerFactory.getLogger("debug"); - private final static Log LOGGER = LogFactory.getLog(LogUtil4j.class); + public static Logger LOGGER = LoggerFactory.getLogger(LogUtil4j.class); private static RuntimeMXBean runtimeMXBean=ManagementFactory.getRuntimeMXBean(); diff --git a/src/main/java/com/lp/util/ResultMapUtils.java b/src/main/java/com/lp/util/ResultMapUtils.java index 67d9d08..8221f4d 100644 --- a/src/main/java/com/lp/util/ResultMapUtils.java +++ b/src/main/java/com/lp/util/ResultMapUtils.java @@ -330,7 +330,8 @@ public class ResultMapUtils { protected void exception(Exception e, Object... param) { if (param != null && param.length > 0) { LogUtil.errorLog(new Object[] { param.getClass().getSimpleName() }, new Object[] { param }, e.getMessage()); - } + } + LogUtil4j.debugLogger.error("error: ", e); LogUtil.errorLog(e); } diff --git a/src/main/java/com/lp/util/iot/ProtocolUtil.java b/src/main/java/com/lp/util/iot/ProtocolUtil.java index 6d9299e..6832169 100644 --- a/src/main/java/com/lp/util/iot/ProtocolUtil.java +++ b/src/main/java/com/lp/util/iot/ProtocolUtil.java @@ -26,7 +26,7 @@ public class ProtocolUtil { * @return */ public static Integer sendControlSensorCommand(IotSensorInfoBO obj ){ - LogUtil4j.debugLogger.debug("called with {}", obj); + LogUtil4j.debugLogger.debug("called with {}, {}", obj.getId(), obj.getRequest_sdata()); //IOT_SERVER_LPM:TYPE,deviceCode,SENSOR_DEVICE_ID,PORT_ID,DATA,FORMULATE StringBuffer strBuffer = new StringBuffer(); diff --git a/src/main/webapp/WEB-INF/oss/iot/sensors_manger.jsp b/src/main/webapp/WEB-INF/oss/iot/sensors_manger.jsp index bd64259..cc51948 100644 --- a/src/main/webapp/WEB-INF/oss/iot/sensors_manger.jsp +++ b/src/main/webapp/WEB-INF/oss/iot/sensors_manger.jsp @@ -14,7 +14,20 @@ <%@ include file="/WEB-INF/oss/iot/common/variable.jsp"%> <%@ include file="/WEB-INF/oss/iot/common/variable_js.jsp"%> <%@ include file="/WEB-INF/oss/iot/common/resource_lib.jsp"%> + +