feat:新增传感器的模板导入功能,及小修复
parent
c2fb4127d2
commit
f9ac059632
|
|
@ -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))))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class IotSceneUserRelationController extends BaseController {
|
|||
@RequestParam Integer paged ) {
|
||||
Map<String, Object> resultMap = getResultMap();
|
||||
try {
|
||||
|
||||
|
||||
resultMap = service.selectPageList("IotSceneUserRelation.selectPage",getPageBean(paged,pageSize), obj);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -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<String, Object> 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<String, Object> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -12,5 +12,7 @@ public interface IotSceneInfoService {
|
|||
* @return
|
||||
*/
|
||||
Map<String, Object> getSceneDetailInfo(IotSceneInfoBO tmp);
|
||||
|
||||
|
||||
int insertSceneUserRelationForSupper(Integer id);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, Object> updateRealTimeData(IotSensorInfoBO tmp);
|
||||
|
||||
Map<String, Object> importTemplateSensorInfo(MultipartFile file, String node_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<UserInfoBO> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, Object> 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<String, Object> 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<String, Object> importTemplateSensorInfo(MultipartFile file, String node_id) {
|
||||
Map<String,Object> 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<IotImportSensorInfoBO> 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<String> sensorSet = new HashSet<>();
|
||||
List<ProDictionaryInfo> measure_unit_types = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "20", new ProDictionaryInfoBO()).getSub();
|
||||
List<ProDictionaryInfo> iot_sensor_types = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "24", new ProDictionaryInfoBO()).getSub();
|
||||
List<ProDictionaryInfo> 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() ) ){
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 ){
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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"%>
|
||||
<script type="text/javascript" src="<%=basePath%>/lib/webUploader/webuploader.min.js"></script>
|
||||
<link rel="stylesheet" href="/lib/element-ui/index.css"/>
|
||||
<style type="text/css">
|
||||
.webuploader-element-invisible{
|
||||
display: none !important;
|
||||
}
|
||||
.download{
|
||||
text-align: center;
|
||||
text-decoration: underline;
|
||||
color: #3499da;
|
||||
font-size: 16px;
|
||||
padding-top: 15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.index_theLeft ul {
|
||||
width: 100%;
|
||||
padding: 0px;
|
||||
|
|
@ -96,7 +109,22 @@
|
|||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<div style="padding-top: 15px;">
|
||||
<button onclick="addSensor()" class="button button-small small ml-20 bg-iot">新增传感点</button>
|
||||
|
||||
<div class="upload_img" id="upload_file"
|
||||
style="display: inline-block; position: relative; width: 150px;">
|
||||
<button class="button button-small ml-20 bg-iot">
|
||||
<span class="icon-cloud-upload"></span> 导入
|
||||
</button>
|
||||
</div>
|
||||
<button onclick="window.open('<%=basePath%>/file/excel/传感器导入模板.xlsx')" class="button button-small small ml-20 bg-iot "><span class="icon-download"></span> 模板下载</button>
|
||||
<%-- <button id="excel-down" onclick="excelDown()" class="button button-small small ml-20 bg-iot float-right">模板下载</button>--%>
|
||||
<%-- <button id="all-export" onclick="allexport()" class="button button-small small ml-20 bg-iot float-right">导出</button>--%>
|
||||
<%-- <button id="all-delete" onclick="deleteSensors()" class="button button-small small ml-20 " style="background: #e33;color:#fff;" >全部删除</button>--%>
|
||||
</div>
|
||||
<div class="container-layout sceneList-info" style="position: relative;">
|
||||
|
||||
<div class="box join-device-box">
|
||||
<input class="node_id" type="hidden" >
|
||||
<input class="sensor_device_id" type="hidden">
|
||||
|
|
@ -114,8 +142,9 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<img title="增加传感器" alt="增加传感器" style="cursor:pointer;width:45px;position:absolute;bottom: 11%;right:6%;" onclick="addSensor()" src="<%=sensorImg%>/add.png">
|
||||
<%-- <img title="增加传感器" alt="增加传感器" style="cursor:pointer;width:45px;position:absolute;bottom: 11%;right:6%;" onclick="addSensor()" src="<%=sensorImg%>/add.png">--%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -179,9 +208,52 @@ function addSensor(){
|
|||
forwardUrl("/iot/sensor_info_detail?id="+ $(".node_id").val() + subUrl ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
*/
|
||||
function excelDown(){
|
||||
window.open(localUrl + "/sensor/export/empty");
|
||||
}
|
||||
/**
|
||||
* 传感器列表导出
|
||||
*/
|
||||
function allexport(){
|
||||
window.open(localUrl + "/sensor/export?node_id=" + GetQueryString("node_id") );
|
||||
}
|
||||
/**
|
||||
* 全部删除点
|
||||
*/
|
||||
function deleteSensors(){
|
||||
lcomfirm('是否确定删除所有传感点?',function(){
|
||||
commonAjax("DELETE",localUrl + "/sensor/delete?node_id=" + GetQueryString("node_id") , "" ,function(){
|
||||
tip("删除成功");
|
||||
setTimeout(function(){
|
||||
closeAll();
|
||||
$("#init-table").tableAdaptor();
|
||||
},1000)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var node_id = GetQueryString("node_id");
|
||||
var sensor_device_id = GetQueryString("sensor_device_id");
|
||||
|
||||
$(function(){
|
||||
$(".node_id").val( GetQueryString("node_id") );
|
||||
$(".sensor_device_id").val(GetQueryString("sensor_device_id")) ;
|
||||
|
||||
//上传模板
|
||||
UploadInit( localUrl + '/sensor/upload.json' , {"nodeId":node_id} ,function(file,data){
|
||||
if(isOK(data)){
|
||||
tip("导入成功");
|
||||
// reflash( $(".dashboard-menu li.active").attr("sid"));
|
||||
setTimeout(function() {
|
||||
$("#init-table").tableAdaptor();
|
||||
}, 2000);
|
||||
}else{
|
||||
tip(data.statusMsg,3000);
|
||||
}
|
||||
}, "upload_file" ,"","100px", "35px") ;
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
Binary file not shown.
Loading…
Reference in New Issue