fix:增加日志管理模块,对手动下属和触发操作进行记录,同时完善迅饶协议的相关处理
parent
272e8006a7
commit
d489e02103
|
|
@ -0,0 +1,36 @@
|
|||
package com.lp.bean;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.codehaus.jackson.map.annotate.JsonSerialize;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*@类:IotHistorySensorData
|
||||
*@作者:chenrj
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IotLogData extends BaseBean {
|
||||
|
||||
/**id*/
|
||||
private Integer id;
|
||||
|
||||
/**sensor_id*/
|
||||
private Integer sensor_id;
|
||||
|
||||
/**sdata*/
|
||||
private String sdata;
|
||||
|
||||
/**aid*/
|
||||
private Integer aid;
|
||||
|
||||
/**atime*/
|
||||
private Date atime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.lp.bean;
|
||||
|
||||
import com.lp.annotation.Code;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.codehaus.jackson.map.annotate.JsonSerialize;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*@类:IotAlarmInfo
|
||||
*@作者:chenrj
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IotTaskRecord extends BaseBean {
|
||||
|
||||
private Integer call_id;
|
||||
private Integer task_id;
|
||||
private Integer task_type;
|
||||
private Integer task_obj;
|
||||
private Integer scene_id=-1;
|
||||
private Integer node_id=-1;
|
||||
private Integer sensor_id=-1;
|
||||
private Integer visual_id=-1;
|
||||
private Integer group_id=-1;
|
||||
private Integer trigger_id=-1;
|
||||
private Integer video_id=-1;
|
||||
private Integer cron_id=-1;
|
||||
private Integer task_result;
|
||||
private Date task_time;
|
||||
private String task_data;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.lp.bo;
|
||||
|
||||
import com.lp.bean.IotAlarmInfo;
|
||||
import com.lp.bean.IotTaskRecord;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.codehaus.jackson.map.annotate.JsonSerialize;
|
||||
|
||||
/**
|
||||
* @类:IotAlarmInfo
|
||||
* @作者:chenrj
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IotTaskRecordBO extends IotTaskRecord {
|
||||
|
||||
public IotTaskRecordBO(Integer id) {
|
||||
super();
|
||||
this.setId(id);
|
||||
}
|
||||
|
||||
private String call_name ;
|
||||
private String type_name ;
|
||||
private String obj_name ;
|
||||
private String scene_name;
|
||||
private String node_name;
|
||||
private String sensor_name;
|
||||
private String visual_name;
|
||||
private String group_name;
|
||||
private String trigger_name;
|
||||
private String video_name;
|
||||
private String cron_name;
|
||||
private String result_name;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -82,7 +82,8 @@ public class CacheName {
|
|||
* 传感器设置缓存
|
||||
*/
|
||||
public final static String SENSOR_PARAM_SETTING = "SensorSetting" ;
|
||||
|
||||
public final static String SENSOR_CONTROL = "SensorControl" ;
|
||||
|
||||
|
||||
public final static String SCENE_IPDATE_FLAG = "SceneUpdateFlag" ;
|
||||
|
||||
|
|
|
|||
|
|
@ -250,10 +250,9 @@ public class ProCache extends ResultMapUtils {
|
|||
for(IotSensorInfoBO obj: iotSensorInfoList){
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(obj.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn"))
|
||||
? "" : "-"+obj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO, obj.getId()+"", obj);
|
||||
// LogUtil4j.debugLogger.debug("add cache {}---{}", CacheName.SENSORINFO_NSP
|
||||
// , obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id());
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+obj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO_NSP,
|
||||
obj.getNode_id()+"-"+obj.getSensor_device_id()+port_id, obj);
|
||||
if(obj.getNode_id() == 22) {
|
||||
|
|
@ -325,7 +324,10 @@ public class ProCache extends ResultMapUtils {
|
|||
List<IotSensorInfoBO> iotSensorInfoBOList = baseDao.selectList("IotSensorInfo.selectSensorTriggerList", new IotSensorInfoBO());
|
||||
if( ObjectUtil.isNotEmpty(iotSensorInfoBOList) ){
|
||||
for(IotSensorInfoBO obj: iotSensorInfoBOList){
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, obj.getNode_id()+"-"+ obj.getSensor_device_id()+"-"+obj.getPort_id(), obj);
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(obj.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+obj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, obj.getNode_id()+"-"+ obj.getSensor_device_id()+port_id, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ public class RequestURLIOT {
|
|||
public final static String ALARM_INFO_UNREAD = "/alarm/unread";
|
||||
}
|
||||
|
||||
public class TaskRecord {
|
||||
public final static String TASK_RECORD_PAGE = "/page/task-record";
|
||||
}
|
||||
|
||||
public class TriggerInfo {
|
||||
public final static String TRIGGER_INFO = "/trigger";
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,6 @@ public class IotAlarmInfoController extends BaseController {
|
|||
/**
|
||||
* 查询(未读报警)的数量
|
||||
* @param response
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, value = RequestURLIOT.AlarmInfo.ALARM_INFO_UNREAD)
|
||||
|
|
|
|||
|
|
@ -410,15 +410,17 @@ public class IotNodeInfoController extends BaseController {
|
|||
obj.setId(id);
|
||||
resultMap = service.delete("IotNodeInfo.deleteNode", obj) ;
|
||||
if(isOk(resultMap)){
|
||||
|
||||
IotNodeInfoBO nobj = ProCacheUtil.getCache(CacheName.NODEINFO, id.toString(), new IotNodeInfoBO());
|
||||
boolean isXRxasn = ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn");
|
||||
// 这边再删除sensorlist 信息
|
||||
IotSensorInfoBO sensorBo = new IotSensorInfoBO() ;
|
||||
sensorBo.setNode_id(id);
|
||||
List<IotSensorInfoBO> sensors = getData( service.selectList("IotSensorInfo.select", sensorBo )) ;
|
||||
if( ObjectUtil.isNotEmpty(sensors) ){
|
||||
for(IotSensorInfoBO t : sensors){
|
||||
String port_id = isXRxasn ? "" : "-"+t.getPort_id();
|
||||
ProCacheUtil.removeCache(CacheName.SENSORINFO , t.getId()+"");
|
||||
ProCacheUtil.removeCache(CacheName.SENSORINFO_NSP, id+"-" +t.getSensor_device_id()+"-"+t.getPort_id() );
|
||||
ProCacheUtil.removeCache(CacheName.SENSORINFO_NSP, id+"-" +t.getSensor_device_id()+port_id );
|
||||
}
|
||||
// 删除所有传感器
|
||||
service.delete("IotSensorInfo.deleteSensorByNodeId", sensorBo ) ;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,30 @@ public class IotSceneInfoController extends BaseController {
|
|||
}
|
||||
return getModelAndView(response, resultMap);
|
||||
}
|
||||
/**
|
||||
* 检索
|
||||
* @param response
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = RequestURLIOT.SceneInfo.SCENE_INFO_PAGE)
|
||||
public ModelAndView select(HttpServletResponse response,
|
||||
@RequestHeader(value = ResultMapUtils.USER_KEY, required = true) String userKey ,
|
||||
@RequestBody IotSceneInfoBO obj,
|
||||
@RequestParam(required=false) Integer pageSize ,
|
||||
@RequestParam Integer paged ) {
|
||||
Map<String, Object> resultMap = getResultMap();
|
||||
try {
|
||||
UserInfoBO user = getUserInfoByUserKey(userKey);
|
||||
if(user.getType() != Code.UserType.SUPER + 0 ){
|
||||
obj.setUser_id(user.getId());
|
||||
}
|
||||
resultMap = service.selectPageList("IotSceneInfo.select",getPageBean(paged,pageSize), obj);
|
||||
} catch (Exception e) {
|
||||
exception(e,resultMap, obj);
|
||||
}
|
||||
return getModelAndView(response, resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 超管使用检索
|
||||
|
|
@ -123,7 +147,6 @@ public class IotSceneInfoController extends BaseController {
|
|||
@RequestHeader(value = ResultMapUtils.USER_KEY, required = true) String userKey ,
|
||||
@RequestBody IotSceneInfoBO obj ) {
|
||||
Map<String, Object> resultMap = getResultMap();
|
||||
LOGGER.info("{} save is called with: {}", RequestURLIOT.SceneInfo.SCENE_INFO, obj);
|
||||
try {
|
||||
UserInfoBO user = getUserInfoByUserKey(userKey);
|
||||
if(ObjectUtil.isNotEmpty(user)){
|
||||
|
|
@ -140,7 +163,12 @@ public class IotSceneInfoController extends BaseController {
|
|||
// 添加场景缓存
|
||||
ProCacheUtil.addCache(CacheName.SCENEINFO, obj.getId().toString(), obj);
|
||||
}
|
||||
int ret = iotSceneInfoservice.insertSceneUserRelationForSupper(obj.getId());
|
||||
if(user.getId() != 1){
|
||||
tmp.setUser_id(1);
|
||||
tmp.setAid(1);
|
||||
resultMap = service.insert("IotSceneUserRelation.insert", tmp);
|
||||
}
|
||||
// int ret = iotSceneInfoservice.insertSceneUserRelationForSupper(obj.getId());
|
||||
}
|
||||
}else{
|
||||
putStatusCode(resultMap, Code.ResponseCode.SystemCode.NO_AUTHORIZATION);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package com.lp.controller.iot;
|
||||
|
||||
import com.lp.bo.IotSensorDeviceInfoBO;
|
||||
import com.lp.bo.IotSensorInfoBO;
|
||||
import com.lp.bo.IotTriggerInfoBO;
|
||||
import com.lp.bo.UserInfoBO;
|
||||
import com.lp.bo.*;
|
||||
import com.lp.cache.CacheName;
|
||||
import com.lp.cache.ProCacheUtil;
|
||||
import com.lp.common.Code;
|
||||
|
|
@ -98,11 +95,13 @@ public class IotSensorDeviceInfoController extends BaseController {
|
|||
|
||||
service.insert("IotSensorInfo.insert", sensor) ;
|
||||
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(sensor.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ?
|
||||
"" : "-"+sensor.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO, sensor.getId().toString(), sensor);
|
||||
// LogUtil4j.debugLogger.debug("add cache {}---{}", CacheName.SENSORINFO_NSP
|
||||
// , sensor.getNode_id()+"-"+sensor.getSensor_device_id()+"-"+sensor.getPort_id());
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO_NSP, sensor.getNode_id()+"-"+
|
||||
sensor.getSensor_device_id()+"-"+sensor.getPort_id(), sensor);
|
||||
sensor.getSensor_device_id()+port_id, sensor);
|
||||
|
||||
|
||||
// 添加触发器
|
||||
|
|
@ -135,7 +134,7 @@ public class IotSensorDeviceInfoController extends BaseController {
|
|||
|
||||
if( ObjectUtil.isNotEmpty(list) ){
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, sensor.getNode_id()+"-"+
|
||||
sensor.getSensor_device_id()+"-"+sensor.getPort_id(), list.get(0));
|
||||
sensor.getSensor_device_id()+port_id, list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,11 +94,9 @@ public class IotSensorInfoController extends BaseController {
|
|||
resultMap = service.insert("IotSensorInfo.insert", obj) ;
|
||||
if(isOk(resultMap)){
|
||||
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();
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO, obj.getId().toString(), obj);
|
||||
|
||||
// LogUtil4j.debugLogger.debug("add cache {}---{}", CacheName.SENSORINFO_NSP
|
||||
// , obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id());
|
||||
String port_id = (ObjectUtil.isNotEmpty(nodeDt) && nodeDt.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+obj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+port_id, obj);
|
||||
|
||||
// 这边获取到网关的缓存信息,如果是modbus设备,则更新下发的缓存
|
||||
|
|
@ -250,9 +248,12 @@ public class IotSensorInfoController extends BaseController {
|
|||
tmp.setRequest_sdata(obj.getRequest_sdata());
|
||||
tmp.setUser_id(user.getId());
|
||||
tmp.setData_type(-1);
|
||||
tmp.setMtime(new Date());
|
||||
// 发送消息给LPM
|
||||
if( ProtocolUtil.sendControlSensorCommand(obj) >-1){
|
||||
resultMap = service.update("IotSensorInfo.update", tmp) ;
|
||||
resultMap = service.update("IotSensorInfo.update", tmp) ;
|
||||
tmp.setMid(0);
|
||||
ProCacheUtil.addCache(CacheName.SENSOR_CONTROL, tmp.getId().toString(), tmp);
|
||||
}else{
|
||||
LogUtil4j.debugLogger.warn("sendControlSensorCommand failed, will offline device {}", obj.getId());
|
||||
putStatusCode(resultMap, CodeIot.DEVICE_STATUS.OFFLINE);
|
||||
|
|
@ -278,8 +279,10 @@ public class IotSensorInfoController extends BaseController {
|
|||
try {
|
||||
// 通过deviceid,sensorDeviceid,portid
|
||||
IotNodeInfoBO nodeTmp = ProCacheUtil.getCache(CacheName.NODEINFO_DEVICECODE, obj.getDevice_code());
|
||||
String port_id = (ObjectUtil.isNotEmpty(nodeTmp) && nodeTmp.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn"))
|
||||
? "" : "-"+obj.getPort_id();
|
||||
IotSensorInfoBO tmp = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP,
|
||||
nodeTmp.getId()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id() );
|
||||
nodeTmp.getId()+"-"+obj.getSensor_device_id()+port_id );
|
||||
tmp = ProCacheUtil.getCache(CacheName.SENSOR_PARAM_SETTING, tmp.getId().toString()) ;
|
||||
if(ObjectUtil.isNotEmpty(tmp)){
|
||||
resultMap = service.update("IotSensorInfo.update", tmp) ;
|
||||
|
|
@ -313,6 +316,7 @@ public class IotSensorInfoController extends BaseController {
|
|||
if(ObjectUtil.isNotEmpty(obj.getId())){
|
||||
tmp.setId(obj.getId());
|
||||
tmp.setSdata(obj.getSdata());
|
||||
tmp.setRequest_sdata(obj.getSdata());
|
||||
tmp.setUser_id(user.getId());
|
||||
// 这边要处理的
|
||||
tmp.setData_type(-1);
|
||||
|
|
@ -320,6 +324,7 @@ public class IotSensorInfoController extends BaseController {
|
|||
// 发送消息给LPM
|
||||
obj.setData_type(-1);
|
||||
if( ProtocolUtil.sendSensorParamDown(obj) >-1){
|
||||
tmp.setMid(0);
|
||||
ProCacheUtil.addCache(CacheName.SENSOR_PARAM_SETTING, obj.getId()+"", tmp );
|
||||
}else{
|
||||
LogUtil4j.debugLogger.warn("sendSensorParamDown failed, will offline device {}", obj.getId());
|
||||
|
|
@ -379,11 +384,13 @@ public class IotSensorInfoController extends BaseController {
|
|||
obj.setUser_id(user.getId());
|
||||
resultMap = service.update("IotSensorInfo.update", obj) ;
|
||||
if(isOk(resultMap)){
|
||||
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();
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO, obj.getId().toString(), obj);
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id(), obj);
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+port_id, obj);
|
||||
|
||||
// 这边获取到网关的缓存信息,如果是modbus设备,则更新下发的缓存
|
||||
IotNodeInfoBO nodeDt = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString());
|
||||
if(ObjectUtil.isNotEmpty(nodeDt)){
|
||||
if( nodeDt.getIot_node_type()+0 == 83 && nodeDt.getIot_protocal_category().contains("ProtocalModbus") ){
|
||||
// 修改网关信息后,则设置设备重新连接 TCP协议
|
||||
|
|
@ -419,8 +426,11 @@ public class IotSensorInfoController extends BaseController {
|
|||
obj.setMtime(new Date());
|
||||
resultMap = service.update("IotSensorInfo.update", obj) ;
|
||||
if(isOk(resultMap)){
|
||||
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();
|
||||
ProCacheUtil.removeCache(CacheName.SENSORINFO, obj.getId().toString());
|
||||
ProCacheUtil.removeCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id());
|
||||
ProCacheUtil.removeCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+port_id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -461,8 +471,10 @@ public class IotSensorInfoController extends BaseController {
|
|||
try {
|
||||
IotNodeInfoBO iotNodeInfo = ProCacheUtil.getCache(CacheName.NODEINFO_DEVICECODE, obj.getDevice_code());
|
||||
if(ObjectUtil.isNotEmpty(iotNodeInfo)){
|
||||
String port_id = (ObjectUtil.isNotEmpty(iotNodeInfo) && iotNodeInfo.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn"))
|
||||
? "" : "-"+obj.getPort_id();
|
||||
IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP,
|
||||
iotNodeInfo.getId()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id());
|
||||
iotNodeInfo.getId()+"-"+obj.getSensor_device_id()+port_id);
|
||||
putData(resultMap, sensorInfo);
|
||||
}else{
|
||||
putStatusCode(resultMap, Code.ResponseCode.SystemCode.NO_DATA) ;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.lp.controller.iot;
|
||||
|
||||
import com.lp.bo.IotAlarmInfoBO;
|
||||
import com.lp.bo.IotTaskRecordBO;
|
||||
import com.lp.bo.UserInfoBO;
|
||||
import com.lp.common.Code;
|
||||
import com.lp.common.CodeIot;
|
||||
import com.lp.common.Constants;
|
||||
import com.lp.common.RequestURLIOT;
|
||||
import com.lp.controller.BaseController;
|
||||
import com.lp.util.DateUtils;
|
||||
import com.lp.util.ObjectUtil;
|
||||
import com.lp.util.ResultMapUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Controller
|
||||
public class IotTaskRecordController extends BaseController {
|
||||
|
||||
/**
|
||||
* 检索
|
||||
* @param response
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, value = RequestURLIOT.TaskRecord.TASK_RECORD_PAGE)
|
||||
public ModelAndView selectPage(HttpServletResponse response,
|
||||
@RequestHeader(value = ResultMapUtils.USER_KEY, required = true) String userKey ,
|
||||
@RequestBody IotTaskRecordBO obj,
|
||||
@RequestParam(required=false) Integer pageSize ,
|
||||
@RequestParam Integer paged ) {
|
||||
Map<String, Object> resultMap = getResultMap();
|
||||
try {
|
||||
UserInfoBO user = getUserInfoByUserKey(userKey);
|
||||
obj.setUser_id(user.getId());
|
||||
resultMap = service.selectPageList("IotTaskRecord.selectPage",getPageBean(paged,pageSize), obj);
|
||||
} catch (Exception e) {
|
||||
exception(e,resultMap, obj);
|
||||
}
|
||||
return getModelAndView(response, resultMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.lp.bo.IotNodeInfoBO;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
|
@ -78,8 +79,11 @@ public class IotTriggerInfoController extends BaseController {
|
|||
resultMap = service.selectList("IotSensorInfo.selectSensorTriggerList", new IotSensorInfoBO(obj.getFrom_sensor_id()));
|
||||
if(isOk(resultMap)){
|
||||
IotSensorInfoBO iotSensorObj = ((List<IotSensorInfoBO>) getData(resultMap)).get(0);
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(obj.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+iotSensorObj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+"-"+iotSensorObj.getPort_id(), iotSensorObj);
|
||||
iotSensorObj.getSensor_device_id()+port_id, iotSensorObj);
|
||||
|
||||
// 判断
|
||||
if(obj.getIot_trigger_condition_type() == 280){
|
||||
|
|
@ -151,35 +155,42 @@ public class IotTriggerInfoController extends BaseController {
|
|||
if(ObjectUtil.isNotEmpty(osensorId)){
|
||||
// 更新触发器缓存
|
||||
resultMap = service.selectList("IotSensorInfo.selectSensorTriggerList", new IotSensorInfoBO(osensorId));
|
||||
IotSensorInfoBO iotSensorObj = null ;
|
||||
IotSensorInfoBO iotSensorObj = null ;
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(obj.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
if(isOk(resultMap)){
|
||||
iotSensorObj = ((List<IotSensorInfoBO>) getData(resultMap)).get(0);
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+"-"+iotSensorObj.getPort_id(), iotSensorObj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+iotSensorObj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+port_id, iotSensorObj);
|
||||
}else{
|
||||
// 这边没有了
|
||||
iotSensorObj = ProCacheUtil.getCache(CacheName.SENSORINFO, osensorId +"");
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+iotSensorObj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+"-"+iotSensorObj.getPort_id(), iotSensorObj);
|
||||
|
||||
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(obj.getNode_id()) && obj.getNode_id() != iotSensorObj.getNode_id()+0){
|
||||
onodeId = iotSensorObj.getNode_id() ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 检索最新更新传感器
|
||||
resultMap = service.selectOne("IotTriggerInfo.selectOne", new IotTriggerInfoBO(obj.getId()));
|
||||
obj = (IotTriggerInfoBO) getData(resultMap) ;
|
||||
|
||||
|
||||
// 更新触发器缓存
|
||||
resultMap = service.selectList("IotSensorInfo.selectSensorTriggerList", new IotSensorInfoBO(obj.getFrom_sensor_id()));
|
||||
if(isOk(resultMap)){
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(obj.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
IotSensorInfoBO iotSensorObj = ((List<IotSensorInfoBO>) getData(resultMap)).get(0);
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+"-"+iotSensorObj.getPort_id(), iotSensorObj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+iotSensorObj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+port_id, iotSensorObj);
|
||||
}
|
||||
|
||||
|
||||
// 网关离线的触发器更新
|
||||
IotTriggerInfoBO triggerInfo = new IotTriggerInfoBO();
|
||||
triggerInfo.setIot_trigger_condition_type(280);
|
||||
|
|
@ -260,14 +271,19 @@ public class IotTriggerInfoController extends BaseController {
|
|||
resultMap = service.selectList("IotSensorInfo.selectSensorTriggerList", new IotSensorInfoBO(obj.getFrom_sensor_id()));
|
||||
if(isOk(resultMap)){
|
||||
IotSensorInfoBO iotSensorObj = ((List<IotSensorInfoBO>) getData(resultMap)).get(0);
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(obj.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+iotSensorObj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+"-"+iotSensorObj.getPort_id(), iotSensorObj);
|
||||
iotSensorObj.getSensor_device_id()+port_id, iotSensorObj);
|
||||
}else{
|
||||
// 如果没有了,则需要
|
||||
IotSensorInfoBO iotSensorObj = ProCacheUtil.getCache(CacheName.SENSORINFO, obj.getFrom_sensor_id()+"");
|
||||
|
||||
IotNodeInfoBO nobj = new IotNodeInfoBO(obj.getNode_id());
|
||||
nobj = ProCacheUtil.getCache(CacheName.NODEINFO, obj.getNode_id().toString(), nobj);
|
||||
String port_id = (ObjectUtil.isNotEmpty(nobj) && nobj.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn")) ? "" : "-"+iotSensorObj.getPort_id();
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, iotSensorObj.getNode_id()+"-"+
|
||||
iotSensorObj.getSensor_device_id()+"-"+iotSensorObj.getPort_id(), iotSensorObj);
|
||||
iotSensorObj.getSensor_device_id()+port_id, iotSensorObj);
|
||||
}
|
||||
|
||||
// 更新这个设备node的触发器
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="IotTaskRecord">
|
||||
<!-- 新增, 并返回id -->
|
||||
<insert id="insert" parameterType="com.lp.bo.IotTaskRecordBO">
|
||||
INSERT INTO iot_task_record
|
||||
(call_id,task_id,task_type,task_obj,scene_id,node_id,sensor_id,visual_id
|
||||
,group_id,trigger_id,video_id,cron_id,task_result,task_data)
|
||||
VALUES
|
||||
(#{call_id},#{task_id},#{task_type},#{task_obj},#{scene_id},#{node_id},#{sensor_id},#{visual_id}
|
||||
,#{group_id},#{trigger_id},#{video_id},#{cron_id},#{task_result},#{task_data})
|
||||
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
|
||||
select id from iot_task_record ORDER BY id desc LIMIT 1
|
||||
</selectKey>
|
||||
</insert>
|
||||
|
||||
<!-- 检索记录 -->
|
||||
<select id="selectOne" parameterType="com.lp.bo.IotTaskRecordBO"
|
||||
resultType="com.lp.bo.IotTaskRecordBO">
|
||||
<include refid="sql_select_field"/>
|
||||
WHERE o.id=#{id} LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 检索记录字段 -->
|
||||
<sql id="sql_select_field">
|
||||
select o.id, call_id, task_id, task_type, task_obj, scene_id, node_id, sensor_id, visual_id, group_id, trigger_id, video_id
|
||||
, cron_id, task_result, task_time, task_data
|
||||
, if(task_type = 453,(select name from user_info where id = call_id), if(task_type = 455, (select name from iot_trigger_info where id = call_id), null)) as call_name
|
||||
, (select name from iot_scene_info where id = scene_id) as scene_name
|
||||
, (select name from iot_node_info where id = node_id) as node_name
|
||||
, (select name from iot_sensor_info where id = sensor_id) as sensor_name
|
||||
, (select name from iot_visual_display_info where id = visual_id) as visual_name
|
||||
, (select name from iot_trigger_info where id = trigger_id) as trigger_name
|
||||
, (select name from iot_video_info where id = video_id) as video_name
|
||||
, pdi1.name as type_name, pdi2.name as obj_name, pdi3.name as result_name
|
||||
from iot_task_record o
|
||||
left join pro_dictionary_info pdi1 on o.task_type = pdi1.code and pdi1.p_code = 449
|
||||
left join pro_dictionary_info pdi2 on o.task_obj = pdi2.code and pdi2.p_code = 450
|
||||
left join pro_dictionary_info pdi3 on o.task_result = pdi3.code and pdi3.p_code = 451
|
||||
</sql>
|
||||
|
||||
<!-- 检索记录条件 -->
|
||||
<sql id="sql_select_condition">
|
||||
WHERE 1=1
|
||||
<if test="id_array!=null">
|
||||
AND o.id IN
|
||||
<foreach collection="id_array" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="id!=null">
|
||||
AND o.id=#{id}
|
||||
</if>
|
||||
<if test="call_id != null and call_id != ''"> AND o.call_id = ${call_id} </if>
|
||||
<if test="task_id != null and task_id != ''"> AND o.task_id = ${task_id} </if>
|
||||
<if test="task_type != null and task_type != ''"> AND o.task_type = ${task_type} </if>
|
||||
<if test="task_obj != null and task_obj != ''"> AND o.task_obj = ${task_obj} </if>
|
||||
<if test="scene_id != null and scene_id != '' and scene_id != -1"> AND o.scene_id = ${scene_id} </if>
|
||||
<if test="node_id != null and node_id != '' and node_id != -1"> AND o.node_id = ${node_id} </if>
|
||||
<if test="sensor_id != null and sensor_id != '' and sensor_id != -1"> AND o.sensor_id = ${sensor_id} </if>
|
||||
<if test="visual_id != null and visual_id != '' and visual_id != -1"> AND o.visual_id = ${visual_id} </if>
|
||||
<if test="group_id != null and group_id != '' and group_id != -1"> AND o.group_id = ${group_id} </if>
|
||||
<if test="trigger_id != null and trigger_id != '' and trigger_id != -1"> AND o.trigger_id = ${trigger_id} </if>
|
||||
<if test="video_id != null and video_id != '' and video_id != -1"> AND o.video_id = ${video_id} </if>
|
||||
<if test="cron_id != null and cron_id != '' and cron_id != -1"> AND o.cron_id = ${cron_id} </if>
|
||||
<if test="task_result!= null and task_result!= ''"> AND o.task_result = ${task_result} </if>
|
||||
<if test="task_time != null and task_time != ''"> AND o.task_time = ${task_time} </if>
|
||||
<if test="task_data != null and task_data != ''"> AND o.task_data = ${task_data} </if>
|
||||
<if test="type_name !=null and type_name !=''">
|
||||
AND o.task_type IN ( SELECT code FROM pro_dictionary_info WHERE p_code = 449 and name LIKE CONCAT("%", #{type_name},"%") )
|
||||
</if>
|
||||
<if test="obj_name !=null and obj_name !=''">
|
||||
AND o.task_obj IN ( SELECT code FROM pro_dictionary_info WHERE p_code = 450 and name LIKE CONCAT("%", #{obj_name},"%") )
|
||||
</if>
|
||||
<if test="result_name !=null and result_name !=''">
|
||||
AND o.task_result IN ( SELECT code FROM pro_dictionary_info WHERE p_code = 451 and name LIKE CONCAT("%", #{result_name},"%") )
|
||||
</if>
|
||||
<if test="scene_name !=null and scene_name !=''">
|
||||
AND o.scene_id IN ( SELECT id FROM iot_scene_info WHERE name LIKE CONCAT("%", #{scene_name},"%") )
|
||||
</if>
|
||||
<if test="node_name !=null and node_name !=''">
|
||||
AND o.node_id IN ( SELECT id FROM iot_node_info WHERE name LIKE CONCAT("%", #{node_name},"%") )
|
||||
</if>
|
||||
<if test="sensor_name !=null and sensor_name !=''">
|
||||
AND o.sensor_id IN ( SELECT id FROM iot_sensor_info WHERE name LIKE CONCAT("%", #{sensor_name},"%") )
|
||||
</if>
|
||||
<if test="visual_name !=null and visual_name !=''">
|
||||
AND o.visual_id IN ( SELECT id FROM iot_visual_display_info WHERE name LIKE CONCAT("%", #{visual_name},"%") )
|
||||
</if>
|
||||
<if test="trigger_name !=null and trigger_name !=''">
|
||||
AND o.trigger_id IN ( SELECT id FROM iot_trigger_info WHERE name LIKE CONCAT("%", #{trigger_name},"%") )
|
||||
</if>
|
||||
<if test="video_name !=null and video_name !=''">
|
||||
AND o.video_id IN ( SELECT id FROM iot_video_info WHERE name LIKE CONCAT("%", #{video_name},"%") )
|
||||
</if>
|
||||
<if test="start_time !=null and start_time!=''">
|
||||
AND o.task_time >= #{start_time}
|
||||
</if>
|
||||
<if test="end_time !=null and end_time!=''">
|
||||
AND o.task_time <= #{end_time}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 检索记录列表 -->
|
||||
<select id="select" parameterType="com.lp.bo.IotTaskRecordBO"
|
||||
resultType="com.lp.bo.IotTaskRecordBO">
|
||||
<include refid="sql_select_field" />
|
||||
<include refid="sql_select_condition" />
|
||||
ORDER BY o.id DESC
|
||||
</select>
|
||||
|
||||
<!-- 检索记录列表 -->
|
||||
<select id="selectPage" parameterType="com.lp.bo.IotTaskRecordBO"
|
||||
resultType="com.lp.bo.IotTaskRecordBO">
|
||||
<include refid="sql_select_field" />
|
||||
<include refid="sql_select_condition" />
|
||||
ORDER BY o.id DESC
|
||||
<include refid="Base.sql_limit_condition" />
|
||||
</select>
|
||||
|
||||
<!-- 检索记录数量 -->
|
||||
<select id="selectPageCount" resultType="java.lang.Integer" parameterType="com.lp.bo.IotTaskRecordBO">
|
||||
SELECT COUNT(1) FROM iot_task_record o
|
||||
<include refid="sql_select_condition" />
|
||||
</select>
|
||||
|
||||
<!-- 检索记录列表 -->
|
||||
<select id="selectAll" parameterType="com.lp.bo.IotTaskRecordBO"
|
||||
resultType="com.lp.bo.IotAlarmInfoBO">
|
||||
<include refid="sql_select_field" />
|
||||
<include refid="sql_select_condition" />
|
||||
ORDER BY o.id DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -8,17 +8,18 @@ import com.lp.cache.CacheName;
|
|||
import com.lp.cache.ProCacheUtil;
|
||||
import com.lp.common.CodeIot;
|
||||
import com.lp.mqtt.MqttService;
|
||||
import com.lp.service.base.IotLoggingService;
|
||||
import com.lp.service.base.impl.IotLoggingServiceImpl;
|
||||
import com.lp.service.impl.IotNodeInfoServerImpl;
|
||||
import com.lp.service.impl.IotSensorInfoServiceImpl;
|
||||
import com.lp.util.LogUtil4j;
|
||||
import com.lp.util.ObjectUtil;
|
||||
import com.lp.util.SpringApplicationContext;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
@ -41,16 +42,53 @@ public class ProtocalXRxasn implements Iprotocal {
|
|||
List<IotSensorInfoBO> list = new ArrayList<>();
|
||||
|
||||
XRxasnProtocolMqtt xRxasnProtocolMqtt = JSON.parseObject(msg, XRxasnProtocolMqtt.class);
|
||||
String deviceCode = xRxasnProtocolMqtt.getSn();
|
||||
|
||||
IotNodeInfoBO nodeInfo = ProCacheUtil.getCache(CacheName.NODEINFO_DEVICECODE, deviceCode );
|
||||
if(ObjectUtil.isEmpty(nodeInfo)){
|
||||
LogUtil4j.debugLogger.warn("get no nodeInfo with {}", deviceCode);
|
||||
return ;
|
||||
}
|
||||
|
||||
if(ObjectUtil.isNotEmpty(xRxasnProtocolMqtt.getType()) && !topic.endsWith("/rtg")){
|
||||
if(topic.endsWith("cmd/set/cack")){
|
||||
IotLoggingServiceImpl iotLoggingService = (IotLoggingServiceImpl) SpringApplicationContext.getBean("iotLoggingServiceImpl") ;
|
||||
XRsasnTag xRsasnTag = JSON.parseObject(xRxasnProtocolMqtt.getData().toString(), XRsasnTag.class);
|
||||
String sensor_device_id = xRsasnTag.getDev() + "." + xRsasnTag.getM();
|
||||
IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP, nodeInfo.getId()+"-"+sensor_device_id, new IotSensorInfoBO());
|
||||
IotSensorInfoBO tmp = ProCacheUtil.getCache(CacheName.SENSOR_CONTROL, sensorInfo.getId().toString(), sensorInfo);
|
||||
if(ObjectUtil.isNotEmpty(tmp)) {
|
||||
ProCacheUtil.removeCache(CacheName.SENSOR_CONTROL, sensorInfo.getId().toString());
|
||||
}
|
||||
else {
|
||||
tmp = ProCacheUtil.getCache(CacheName.SENSOR_PARAM_SETTING, sensorInfo.getId().toString(), sensorInfo);
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(tmp)) {
|
||||
ProCacheUtil.removeCache(CacheName.SENSOR_PARAM_SETTING, sensorInfo.getId().toString());
|
||||
}
|
||||
else {
|
||||
LogUtil4j.LOGGER.warn("can not find sensor param with {}", sensorInfo.getId());
|
||||
return;
|
||||
}
|
||||
// tmp.setSdata(xRsasnTag.getV());
|
||||
tmp.setNode_id(nodeInfo.getId());
|
||||
tmp.setScene_id(nodeInfo.getScene_id());
|
||||
tmp.setSeq(Integer.valueOf(xRxasnProtocolMqtt.getSeq()));
|
||||
if(xRsasnTag.getValid() == 1 && xRsasnTag.getRemark().equals("success")) {
|
||||
IotSensorInfoBO tp = new IotSensorInfoBO();
|
||||
tp.setSensor_device_id(xRsasnTag.getDev() + "." + xRsasnTag.getM());
|
||||
tp.setSensor_device_id(sensor_device_id);
|
||||
tp.setSdata(xRsasnTag.getV());
|
||||
list.add(tp);
|
||||
tmp.setSensor_device_id(sensor_device_id);
|
||||
tmp.setInfos("0");
|
||||
iotLoggingService.writeLog(ObjectUtil.isNotEmpty(tmp.getMid()) ? tmp.getMid() : 0, 2, tmp);
|
||||
}
|
||||
else return;
|
||||
else {
|
||||
tmp.setInfos("1");
|
||||
tmp.setSensor_device_id(sensor_device_id);
|
||||
iotLoggingService.writeLog(ObjectUtil.isNotEmpty(tmp.getMid()) ? tmp.getMid() : 0, 2, tmp);
|
||||
return;
|
||||
};
|
||||
}
|
||||
else return;
|
||||
} else if (topic.endsWith("/rtg") && ObjectUtil.isEmpty(xRxasnProtocolMqtt.getType())) {
|
||||
|
|
@ -70,14 +108,7 @@ public class ProtocalXRxasn implements Iprotocal {
|
|||
LogUtil4j.LOGGER.info("msg from topic {} without sub", topic);
|
||||
return;
|
||||
}
|
||||
String deviceCode = xRxasnProtocolMqtt.getSn();
|
||||
|
||||
IotNodeInfoBO nodeInfo = ProCacheUtil.getCache(CacheName.NODEINFO_DEVICECODE, deviceCode );
|
||||
if(ObjectUtil.isEmpty(nodeInfo)){
|
||||
LogUtil4j.debugLogger.warn("get no nodeInfo with {}", deviceCode);
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
if(nodeInfo.getIot_node_status() != CodeIot.DEVICE_STATUS.ONLINE){
|
||||
IotNodeInfoBO nodB = new IotNodeInfoBO() ;
|
||||
nodB.setDevice_code(deviceCode);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
package com.lp.service.base;
|
||||
|
||||
public interface IotLoggingService {
|
||||
|
||||
void writeLog(int type, int obj_type, Object data);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package com.lp.service.base.impl;
|
||||
|
||||
import com.lp.bean.ProDictionaryInfo;
|
||||
import com.lp.bo.IotSensorInfoBO;
|
||||
import com.lp.bo.IotTaskRecordBO;
|
||||
import com.lp.bo.ProDictionaryInfoBO;
|
||||
import com.lp.cache.CacheName;
|
||||
import com.lp.cache.ProCache;
|
||||
import com.lp.cache.ProCacheUtil;
|
||||
import com.lp.dao.BaseDao;
|
||||
import com.lp.service.base.IotLoggingService;
|
||||
import com.lp.service.impl.BaseServiceImpl;
|
||||
import com.lp.util.LogUtil;
|
||||
import com.lp.util.LogUtil4j;
|
||||
import com.lp.util.ObjectUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 短信服务
|
||||
*
|
||||
*/
|
||||
|
||||
@Service
|
||||
@DependsOn(value = {"taskExecutor" , "applicationContext"})
|
||||
public class IotLoggingServiceImpl extends BaseServiceImpl implements IotLoggingService {
|
||||
|
||||
@Autowired
|
||||
private TaskExecutor taskExecutor ;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("baseDao")
|
||||
protected BaseDao dao;
|
||||
|
||||
private ProDictionaryInfoBO obj = new ProDictionaryInfoBO();
|
||||
|
||||
private List<ProDictionaryInfo> task_types = null;
|
||||
private List<ProDictionaryInfo> task_objs = null;
|
||||
private List<ProDictionaryInfo> task_rets = null;
|
||||
private List<ProDictionaryInfo> task_status = null;
|
||||
|
||||
/**
|
||||
* 记录任务结果
|
||||
*
|
||||
* @param type 任务类型 0手动或1定时自动或2触发
|
||||
* @param obj_type 对象类型 0-7,默认-1,项目,设备,传感器,组态,群组,触发器,摄像头,定时任务
|
||||
* @param data 数据
|
||||
* @returnq
|
||||
*/
|
||||
@Override
|
||||
public void writeLog(int type, int obj_type, Object data) {
|
||||
init();
|
||||
try{
|
||||
taskExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if(obj_type == 2){
|
||||
IotSensorInfoBO sensor = (IotSensorInfoBO) data;
|
||||
IotTaskRecordBO iotTaskRecordBO = new IotTaskRecordBO();
|
||||
iotTaskRecordBO.setCall_id(sensor.getUser_id());
|
||||
iotTaskRecordBO.setTask_id(sensor.getSeq());
|
||||
iotTaskRecordBO.setTask_type(task_types == null ? null : task_types.parallelStream().filter(v->v.getValue().equals(type+"")).findAny().get().getCode());
|
||||
iotTaskRecordBO.setTask_obj(task_objs == null ? null : task_objs.parallelStream().filter(v->v.getValue().equals(obj_type + "")).findAny().get().getCode());
|
||||
iotTaskRecordBO.setScene_id(sensor.getScene_id());
|
||||
iotTaskRecordBO.setNode_id(sensor.getNode_id());
|
||||
iotTaskRecordBO.setSensor_id(sensor.getId());
|
||||
iotTaskRecordBO.setTask_result(task_rets == null ? null : task_rets.parallelStream().filter(v->v.getValue().equals(sensor.getInfos())).findAny().get().getCode());
|
||||
// iotTaskRecordBO.setTask_time(sensor.getMtime());
|
||||
iotTaskRecordBO.setTask_data("下发数据: " + sensor.getRequest_sdata()+"");
|
||||
int insert = dao.insert("IotTaskRecord.insert", iotTaskRecordBO);
|
||||
LogUtil4j.debugLogger.info("control: {} with {} by {}", sensor.getSensor_device_id(), sensor.getRequest_sdata(), sensor.getUser_id());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e){
|
||||
LogUtil.errorLog(e);
|
||||
LogUtil4j.LOGGER.error("writeLog wrong: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
void init(){
|
||||
ProDictionaryInfoBO caches = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "449", obj);
|
||||
task_types = ObjectUtil.isNotEmpty(caches) ? caches.getSub() : null;
|
||||
caches = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "450", obj);
|
||||
task_objs = ObjectUtil.isNotEmpty(caches) ? caches.getSub() : null;
|
||||
caches = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "451", obj);
|
||||
task_rets = ObjectUtil.isNotEmpty(caches) ? caches.getSub() : null;
|
||||
caches = ProCacheUtil.getCache(CacheName.DICTIONARY_RELATION, "452", obj);
|
||||
task_status = ObjectUtil.isNotEmpty(caches) ? caches.getSub() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -145,12 +145,13 @@ public class IotNodeInfoServerImpl extends BaseServiceImpl implements IotNodeInf
|
|||
sensor.setMtime(new Date());
|
||||
|
||||
int re = dao.insert("IotSensorInfo.insert", sensor) ;
|
||||
IotNodeInfoBO nodeDt = ProCacheUtil.getCache(CacheName.NODEINFO, sensor.getNode_id().toString());
|
||||
String port_id = (ObjectUtil.isNotEmpty(nodeDt) && nodeDt.getIot_protocal_category().equalsIgnoreCase("ProtocalXRxasn"))
|
||||
? "" : "-"+sensor.getPort_id();
|
||||
if(re>0){
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO, sensor.getId().toString(), sensor);
|
||||
// LogUtil4j.debugLogger.debug("add cache {}---{}", CacheName.SENSORINFO_NSP
|
||||
// , sensor.getNode_id()+"-"+sensor.getSensor_device_id()+"-"+sensor.getPort_id());
|
||||
ProCacheUtil.addCache(CacheName.SENSORINFO_NSP, sensor.getNode_id()+"-"+
|
||||
sensor.getSensor_device_id()+"-"+sensor.getPort_id(), sensor);
|
||||
sensor.getSensor_device_id()+port_id, sensor);
|
||||
}
|
||||
|
||||
// 添加触发器
|
||||
|
|
@ -182,8 +183,8 @@ public class IotNodeInfoServerImpl extends BaseServiceImpl implements IotNodeInf
|
|||
// 更新触发器缓存
|
||||
List<IotSensorInfoBO> list = dao.selectList("IotSensorInfo.selectSensorTriggerList", new IotSensorInfoBO(sensor.getId()));
|
||||
if( ObjectUtil.isNotEmpty(list) ){
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, sensor.getNode_id()+"-"+
|
||||
sensor.getSensor_device_id()+"-"+sensor.getPort_id(), list.get(0));
|
||||
ProCacheUtil.addCache(CacheName.SENSORTRIGGERINFO, sensor.getNode_id()+"-"+
|
||||
sensor.getSensor_device_id()+port_id, list.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class IotSensorInfoServiceImpl extends BaseServiceImpl implements IotSens
|
|||
IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+port_id, obj);
|
||||
|
||||
if( ObjectUtil.isEmpty(sensorInfo) ){
|
||||
LOGGER.warn("updateRealTimeData is called with {} no IotSensorInfoBO", obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id());
|
||||
LOGGER.warn("updateRealTimeData is called with {} no IotSensorInfoBO", obj.getNode_id()+"-"+obj.getSensor_device_id()+port_id);
|
||||
// 不存在的数据
|
||||
return resultMap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ public class IotTrigger {
|
|||
public static Integer trigger(IotSensorInfoBO obj, BaseDao dao){
|
||||
try{
|
||||
// 根据 IotSensorInfoBO 获取触发器列表
|
||||
String sensorDevicePort = obj.getNode_id()+"-"+ obj.getSensor_device_id()+"-"+obj.getPort_id();
|
||||
|
||||
String sensorDevicePort = obj.getNode_id()+"-"+ obj.getSensor_device_id()+(ObjectUtil.isNotEmpty(obj.getPort_id()) ? "-"+obj.getPort_id() : "");
|
||||
// 获取触发器缓存
|
||||
IotSensorInfoBO iotSensorInfoBo = ProCacheUtil.getCache(CacheName.SENSORTRIGGERINFO, sensorDevicePort, obj);
|
||||
|
||||
|
|
@ -152,7 +153,7 @@ public class IotTrigger {
|
|||
}
|
||||
}else if(triggerType.equals( CodeIot.TRIGGER_CONDITION_TYPE.SENSOR_VALUE_MONITOR )){
|
||||
// 传感器数值监控,一直不变情况
|
||||
IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP, obj.getNode_id()+"-"+obj.getSensor_device_id()+"-"+obj.getPort_id());
|
||||
IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP, sensorDevicePort);
|
||||
if (obj.getSdata() == sensorInfo.getSdata()+0 ) {
|
||||
if (decideTrigger(trigger, cacheTrigger, conditions)) {
|
||||
trigger_flag = true;
|
||||
|
|
@ -525,8 +526,8 @@ public class IotTrigger {
|
|||
}
|
||||
}
|
||||
}
|
||||
LogUtil4j.debugLogger.debug("sensor:({}---{}) trigger with ({})"
|
||||
, obj.getDevice_code(), sensorDevicePort, exception_flag);
|
||||
// LogUtil4j.debugLogger.debug("sensor:({}---{}) trigger with ({})"
|
||||
// , obj.getDevice_code(), sensorDevicePort, exception_flag);
|
||||
}catch(Exception e){
|
||||
LogUtil.errorLog(e);
|
||||
return -1 ;
|
||||
|
|
@ -717,7 +718,14 @@ public class IotTrigger {
|
|||
}
|
||||
|
||||
dao.update("IotSensorInfo.update", sensor);
|
||||
|
||||
IotSensorInfoBO tmp = new IotSensorInfoBO(sensor.getId());
|
||||
tmp.setSdata(sensor.getRequest_sdata());
|
||||
tmp.setRequest_sdata(sensor.getRequest_sdata());
|
||||
tmp.setUser_id(trigger.getId());
|
||||
tmp.setData_type(-1);
|
||||
tmp.setMtime(new Date());
|
||||
tmp.setMid(1);
|
||||
ProCacheUtil.addCache(CacheName.SENSOR_CONTROL, sensor.getId().toString(), tmp);
|
||||
// 发送消息给LPM,控制设备
|
||||
ProtocolUtil.sendControlSensorCommand(sensor);
|
||||
return info+"状态;" ;
|
||||
|
|
@ -908,8 +916,9 @@ public class IotTrigger {
|
|||
name += "," +contactUserInfo.getName() ;
|
||||
// 给当前联系人发送微信通知
|
||||
// 传感器缓存
|
||||
String port_id = ObjectUtil.isNotEmpty(param.getPort_id()) ? "-" + param.getPort_id() : "";
|
||||
IotSensorInfoBO sensorInfo = ProCacheUtil.getCache(CacheName.SENSORINFO_NSP, param.getNode_id()+"-"+
|
||||
param.getSensor_device_id()+"-"+param.getPort_id());
|
||||
param.getSensor_device_id()+port_id);
|
||||
// 报警信息
|
||||
param.getNode_name() ;
|
||||
// 当前传感器数值
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
mqtt.clientId=seg_test
|
||||
mqtt.clientId=dev_test
|
||||
mqtt.username=yinzy
|
||||
mqtt.password=yzy123456
|
||||
mqtt.cleanSession=false
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@
|
|||
|
||||
<cache name="SensorSetting" maxElementsInMemory="10000"
|
||||
eternal="false" overflowToDisk="false" timeToIdleSeconds="0" timeToLiveSeconds="600" memoryStoreEvictionPolicy="LFU" />
|
||||
|
||||
<!-- 用于缓存用户对传感器下发的指令-->
|
||||
<cache name="SensorControl" maxElementsInMemory="10000"
|
||||
eternal="false" overflowToDisk="false" timeToIdleSeconds="0" timeToLiveSeconds="600" memoryStoreEvictionPolicy="LFU" />
|
||||
<!-- 用户账户信息 -->
|
||||
<cache name="UserAccountId" maxElementsInMemory="100000"
|
||||
eternal="true" overflowToDisk="false" memoryStoreEvictionPolicy="LFU" />
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ log4j.additivity.org.apache=true
|
|||
log4j.logger.org.springframework=ERROR
|
||||
log4j.logger.freemarker.cache=ERROR
|
||||
#全局的日志级别(打印sql必须要该属性)
|
||||
log4j.appender.Threshold=WARN
|
||||
log4j.appender.Threshold=ERROR
|
||||
|
||||
|
||||
#JDBC config
|
||||
|
|
@ -39,7 +39,7 @@ log4j.logger.org.apache=ERROR
|
|||
|
||||
#ConsoleAppender
|
||||
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.CONSOLE.Threshold=INFO
|
||||
log4j.appender.CONSOLE.Threshold=DEBUG
|
||||
log4j.appender.CONSOLE.Target=System.out
|
||||
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.CONSOLE.layout.ConversionPattern=%d %p [%t] %C.%M(%F:%L) - %m%n
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ function t_delete(obj,i){
|
|||
})
|
||||
}
|
||||
$(function(){
|
||||
|
||||
$(document).delegate(".limiter","click",function(){
|
||||
layer.tips($(this).attr("tag") , this, {
|
||||
tips: [1, '#4682B4']
|
||||
|
|
|
|||
|
|
@ -253,7 +253,22 @@
|
|||
</dl>
|
||||
</li>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${user.type == 10 || user.type == 8 }">
|
||||
<li data-name="logging" class="layui-nav-item">
|
||||
<a href="javascript:;" lay-tips="日志管理" lay-direction="2">
|
||||
<i class="layui-icon layui-icon-chart"></i>
|
||||
<cite>日志管理</cite>
|
||||
</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a lay-href="<%=basePath%>/service/iot/task_record">
|
||||
<i class="layui-icon layui-icon-right"></i>执行记录</a></dd>
|
||||
<%-- <dd><a lay-href="<%=basePath%>/page/myhtml/index.html">--%>
|
||||
<%-- <i class="layui-icon layui-icon-right"></i>数据分析</a></dd>--%>
|
||||
<%-- <dd><a lay-href="<%=basePath%>/service/iot/history_trigger_data">--%>
|
||||
<%-- <i class="layui-icon layui-icon-right"></i>历史触发</a></dd>--%>
|
||||
</dl>
|
||||
</li>
|
||||
</c:if>
|
||||
<c:if test="${user.type == 10 }">
|
||||
<li data-name="system" class="layui-nav-item">
|
||||
<a href="javascript:;" lay-tips="系统设置" lay-direction="2">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<%@ page import="com.lp.cfg.ProConfig"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ 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"%>
|
||||
<link type="text/css" href="<%=basePath%>/css/oss/iot/alarm_manager.css?<%=v%>" rel="stylesheet"/>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<!-- 下方部位 -->
|
||||
<div style="background: #ecf0f5;">
|
||||
<div class="mapContainer" >
|
||||
<div class="app-container">
|
||||
<div class="container-layout sceneList-info">
|
||||
<div class="box join-device-box">
|
||||
<div class="search-container" type-option="search_table" config-option=" submit:'#searchbtns',table:'#init-table'">
|
||||
<span>项目名称:</span>
|
||||
<%--<select type-name="scene_id" class="input input-select input-self">
|
||||
<option value="">选择项目</option>
|
||||
<c:forEach items="${info.data.getData()}" varStatus="status" var="obj">
|
||||
<option value="${obj.id}">${obj.name }</option>
|
||||
</c:forEach>
|
||||
</select>--%>
|
||||
<select type-name="scene_id" type-option="selecter"
|
||||
config-option=" method:'POST','url':'/page/scene-all','key':'id','value':'name',
|
||||
'type':'list' ,init_value:'选择项目' " class="input input-select input-self" ></select>
|
||||
<!-- <span class="ml-10">传感器名称:</span>
|
||||
<input type-name="sensor_name" class="input input-self" /> -->
|
||||
<span class="ml-10">执行结果:</span>
|
||||
<select type-name="task_result" type-option="selecter"
|
||||
config-option=" method:'GET','url':'/dictionary/451','key':'code','value':'name',
|
||||
'type':'list' ,init_value:'选择执行结果' " class="input input-select input-self" ></select>
|
||||
|
||||
<span class="ml-10 ml-10-r">时间区间:</span>
|
||||
<input type-name="start_time" class="input jui-time start_time" data-options="defaultValue:-7" />
|
||||
<span>~</span>
|
||||
<input type-name="end_time" class="input jui-time end_time" data-options="" />
|
||||
<button id="searchbtns" class="button ml-20 bg-iot float-right"><span class="icon-search"></span> 查询</button>
|
||||
</div>
|
||||
|
||||
<div id="init-table" class="jui-table" config-option="url:'/page/task-record',
|
||||
param:{ start_time:'$.start_time$',end_time:'$.end_time$' },
|
||||
columns:[
|
||||
{name:'执行者','value':'call_name','width':'8%'},
|
||||
{name:'执行类型','value':'type_name','width':'9%',limit:26},
|
||||
{name:'项目','value':'scene_name','width':'9%',limit:26},
|
||||
{name:'设备','value':'node_name','width':'7%',limit:26},
|
||||
{name:'传感器','value':'sensor_name','width':'9%',limit:26},
|
||||
{name:'数据','value':'task_data','width':'5%',limit:26},
|
||||
{name:'结果','value':'result_name','width':'6%',style:{'成功':'color,#e33','失败':'color,#CD5C5C',41:'#FF7F50' } },
|
||||
{name:'时间','type':'time','value':'task_time','width':'10%'}]" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
function value_function(data,seq){
|
||||
<c:if test="${user.type == 10 || user.type == 8 }">
|
||||
return "<span tag='删除' onclick='t_delete(this,"+data.id+")' class='self-icon icon-bitbucket'></span>";
|
||||
</c:if>
|
||||
}
|
||||
function t_delete(obj,i){
|
||||
lcomfirm('是否确定删除该报警信息?',function(){
|
||||
commonAjax("DELETE",localUrl+"/alarm?id="+i, '',function(data){
|
||||
if(isOK(data)){
|
||||
tip("删除成功");
|
||||
setTimeout(function(){
|
||||
$("#init-table").tableAdaptor();
|
||||
},1000);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
$(function(){
|
||||
$(document).delegate(".limiter","click",function(){
|
||||
layer.tips($(this).attr("tag") , this, {
|
||||
tips: [1, '#4682B4']
|
||||
});
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<%@ page import="com.lp.cfg.ProConfig"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ 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"%>
|
||||
<link type="text/css" href="<%=basePath%>/css/oss/iot/alarm_manager.css?<%=v%>" rel="stylesheet"/>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<!-- 下方部位 -->
|
||||
<div style="background: #ecf0f5;">
|
||||
<div class="mapContainer" >
|
||||
<div class="app-container">
|
||||
<div class="container-layout sceneList-info">
|
||||
<div class="box join-device-box">
|
||||
<div class="search-container" type-option="search_table" config-option=" submit:'#searchbtns',table:'#init-table'">
|
||||
<span>项目名称:</span>
|
||||
<select type-name="scene_id" class="input input-select input-self">
|
||||
<option value="">选择项目</option>
|
||||
<c:forEach items="${info.data.getData()}" varStatus="status" var="obj">
|
||||
<option value="${obj.id}">${obj.name }</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
<!-- <span class="ml-10">传感器名称:</span>
|
||||
<input type-name="sensor_name" class="input input-self" /> -->
|
||||
<span class="ml-10">执行结果:</span>
|
||||
<select type-name="task_result" type-option="selecter"
|
||||
config-option=" method:'GET','url':'/dictionary/451','key':'code','value':'name',
|
||||
'type':'list' ,init_value:'选择执行结果' " class="input input-select input-self" ></select>
|
||||
|
||||
<span class="ml-10 ml-10-r">时间区间:</span>
|
||||
<input type-name="start_time" class="input jui-time start_time" data-options="defaultValue:-7" />
|
||||
<span>~</span>
|
||||
<input type-name="end_time" class="input jui-time end_time" data-options="" />
|
||||
<button id="searchbtns" class="button ml-20 bg-iot float-right"><span class="icon-search"></span> 查询</button>
|
||||
</div>
|
||||
|
||||
<div id="init-table" class="jui-table" config-option="url:'/page/task-record',
|
||||
param:{ start_time:'$.start_time$',end_time:'$.end_time$' },
|
||||
columns:[
|
||||
{name:'执行者','value':'call_name','width':'8%'},
|
||||
{name:'执行类型','value':'type_name','width':'9%',limit:26},
|
||||
{name:'执行对象','value':'obj_name','width':'9%'},
|
||||
{name:'项目','value':'scene_name','width':'9%',limit:26},
|
||||
{name:'设备','value':'node_name','width':'7%',limit:26},
|
||||
{name:'传感器','value':'sensor_name','width':'9%',limit:26},
|
||||
{name:'数据','value':'task_data','width':'5%',limit:26},
|
||||
{name:'结果','value':'result_name','width':'6%',style:{'成功':'color,#e33','失败':'color,#CD5C5C',41:'#FF7F50' } },
|
||||
{name:'时间','type':'time','value':'task_time','width':'10%'}]" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
function value_function(data,seq){
|
||||
<c:if test="${user.type == 10 || user.type == 8 }">
|
||||
return "<span tag='删除' onclick='t_delete(this,"+data.id+")' class='self-icon icon-bitbucket'></span>";
|
||||
</c:if>
|
||||
}
|
||||
function t_delete(obj,i){
|
||||
lcomfirm('是否确定删除该报警信息?',function(){
|
||||
commonAjax("DELETE",localUrl+"/alarm?id="+i, '',function(data){
|
||||
if(isOK(data)){
|
||||
tip("删除成功");
|
||||
setTimeout(function(){
|
||||
$("#init-table").tableAdaptor();
|
||||
},1000);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
$(function(){
|
||||
$(document).delegate(".limiter","click",function(){
|
||||
layer.tips($(this).attr("tag") , this, {
|
||||
tips: [1, '#4682B4']
|
||||
});
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -180,10 +180,20 @@
|
|||
y = y.replace(/{X}/,array[0]);
|
||||
}
|
||||
if(y.indexOf("{Y}")>0){
|
||||
y = y.replace(/{Y}/,array[1]);
|
||||
if(array.length < 2) {
|
||||
y = y.replace(/{Y}/, array[0]);
|
||||
}
|
||||
else {
|
||||
y = y.replace(/{Y}/, array[1]);
|
||||
}
|
||||
}
|
||||
if(y.indexOf("{M}")>0){
|
||||
y = y.replace(/{M}/,array[1]);
|
||||
if(array.length < 2) {
|
||||
y = y.replace(/{M}/, array[0]);
|
||||
}
|
||||
else {
|
||||
y = y.replace(/{M}/, array[1]);
|
||||
}
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@
|
|||
console.log('连接失败:', error)
|
||||
})
|
||||
client.on('message', function (topic, message, s) {
|
||||
console.log('mqtt reflush with [%s],[%s],[%s] now', topic, message, new Date().getTime());
|
||||
// console.log('mqtt reflush with [%s],[%s],[%s] now', topic, message, new Date().getTime());
|
||||
if (message.toString() == '1') {
|
||||
// if (that.lastTime + 2 * 1000 < new Date().getTime()) {
|
||||
if (that.lastTime + 1 < new Date().getTime()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue