Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
fc3ff5319b
|
|
@ -100,5 +100,16 @@ public class SystemGlobal {
|
||||||
public final static int AQM_TYPE=1804;
|
public final static int AQM_TYPE=1804;
|
||||||
|
|
||||||
public final static int WEEK_DAY=7;
|
public final static int WEEK_DAY=7;
|
||||||
|
/**
|
||||||
|
* 告警默认值
|
||||||
|
*/
|
||||||
|
public final static String WARN_DEFEAT="0";
|
||||||
|
/**
|
||||||
|
* 数据类型
|
||||||
|
*/
|
||||||
|
public final static String FLOAT_TYPE="float";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,23 +150,6 @@ public class BdController {
|
||||||
}
|
}
|
||||||
return AjaxResult.success(0);
|
return AjaxResult.success(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备采集信息上班
|
|
||||||
* @param param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("devInfo")
|
|
||||||
public AjaxResult devInfo(@RequestBody DeviceInfoVo param){
|
|
||||||
try{
|
|
||||||
return service.devInfo(param);
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error(e.toString(),e);
|
|
||||||
}
|
|
||||||
return AjaxResult.success(0);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 设备告警信息上班
|
* 设备告警信息上班
|
||||||
* @param param
|
* @param param
|
||||||
|
|
@ -182,7 +165,20 @@ public class BdController {
|
||||||
return AjaxResult.success(0);
|
return AjaxResult.success(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备采集信息上班
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("devInfo")
|
||||||
|
public AjaxResult devInfo(@RequestBody DeviceInfoVo param){
|
||||||
|
try{
|
||||||
|
return service.devInfo(param);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.securitycontrol.inter.mapper;
|
package com.securitycontrol.inter.mapper;
|
||||||
|
|
||||||
import com.securitycontrol.inter.vo.*;
|
import com.securitycontrol.inter.vo.*;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -88,4 +89,31 @@ public interface BdMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int insertWarn(WarnInfoVo param);
|
int insertWarn(WarnInfoVo param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 依据设备id查询系统 的设备编码
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getDevCodeById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询属性id 依据设备id 属性编码
|
||||||
|
* @param id
|
||||||
|
* @param id1
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SelectDataVo getBdDeviceDetailByIdCode(@Param("id") String id, @Param("code") String id1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入数据
|
||||||
|
* @param selectDataVo
|
||||||
|
*/
|
||||||
|
void insertValue(SelectDataVo selectDataVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入历史数据
|
||||||
|
* @param selectDataVo
|
||||||
|
*/
|
||||||
|
void insertHistoryValue(SelectDataVo selectDataVo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,15 @@ package com.securitycontrol.inter.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.alibaba.nacos.common.utils.UuidUtils;
|
||||||
import com.securitycontrol.common.core.constant.HttpStatus;
|
import com.securitycontrol.common.core.constant.HttpStatus;
|
||||||
import com.securitycontrol.common.core.constant.SecurityConstants;
|
import com.securitycontrol.common.core.constant.SecurityConstants;
|
||||||
import com.securitycontrol.common.core.domain.Result;
|
import com.securitycontrol.common.core.domain.Result;
|
||||||
import com.securitycontrol.common.core.utils.aes.ListHelper;
|
import com.securitycontrol.common.core.utils.aes.ListHelper;
|
||||||
import com.securitycontrol.common.core.utils.aes.StringHelper;
|
import com.securitycontrol.common.core.utils.aes.StringHelper;
|
||||||
|
import com.securitycontrol.common.core.utils.uuid.IdUtils;
|
||||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||||
import com.securitycontrol.entity.system.SystemGlobal;
|
import com.securitycontrol.entity.system.SystemGlobal;
|
||||||
import com.securitycontrol.entity.system.base.vo.ProVo;
|
|
||||||
import com.securitycontrol.inter.mapper.BdMapper;
|
import com.securitycontrol.inter.mapper.BdMapper;
|
||||||
import com.securitycontrol.inter.vo.*;
|
import com.securitycontrol.inter.vo.*;
|
||||||
import com.securitycontrol.system.api.RemoteFileService;
|
import com.securitycontrol.system.api.RemoteFileService;
|
||||||
|
|
@ -21,8 +22,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 边带业务处理层
|
* 边带业务处理层
|
||||||
|
|
@ -159,10 +161,72 @@ public class BdServiceImpl {
|
||||||
*/
|
*/
|
||||||
public AjaxResult devInfo(DeviceInfoVo param) {
|
public AjaxResult devInfo(DeviceInfoVo param) {
|
||||||
try{
|
try{
|
||||||
|
String id=param.getDeviceId();
|
||||||
|
//json数据
|
||||||
|
String json=param.getData();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject data=JSON.parseObject(json);
|
||||||
|
String isWarn=param.getIsWarn();
|
||||||
|
if(StringHelper.isEmpty(isWarn)){
|
||||||
|
isWarn=SystemGlobal.WARN_DEFEAT;
|
||||||
|
}
|
||||||
|
//获取全部key
|
||||||
|
Set<String> keys=data.keySet();
|
||||||
|
String finalIsWarn = isWarn;
|
||||||
|
keys.forEach(key->{
|
||||||
|
//查询系统的id
|
||||||
|
SelectDataVo selectDataVo=mapper.getBdDeviceDetailByIdCode(id,key);
|
||||||
|
//查询存储值
|
||||||
|
String value=data.getString(key);
|
||||||
|
selectDataVo.setValue(value);
|
||||||
|
selectDataVo.setChangeValue(getChangeValue(selectDataVo));
|
||||||
|
selectDataVo.setSourceData(json);
|
||||||
|
selectDataVo.setIsWarn(finalIsWarn);
|
||||||
|
mapper.insertValue(selectDataVo);
|
||||||
|
selectDataVo.setId(IdUtils.getUUId());
|
||||||
|
mapper.insertHistoryValue(selectDataVo);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(),e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据处理
|
||||||
|
* @param vo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getChangeValue(SelectDataVo vo){
|
||||||
|
try{
|
||||||
|
if(StringHelper.isNotEmpty(vo.getDataType())){
|
||||||
|
switch (vo.getDataType()){
|
||||||
|
case SystemGlobal.FLOAT_TYPE:
|
||||||
|
if(StringHelper.isNotEmpty(vo.getHistoryValue())){
|
||||||
|
BigDecimal d1=new BigDecimal(vo.getValue());
|
||||||
|
BigDecimal d2=new BigDecimal(vo.getHistoryValue());
|
||||||
|
BigDecimal resultSub = d1.subtract(d2);
|
||||||
|
return resultSub.toString();
|
||||||
|
}
|
||||||
|
return vo.getValue();
|
||||||
|
default:
|
||||||
|
return vo.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.securitycontrol.inter.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备 推送数据解析
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DetailsVo {
|
||||||
|
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private String minValue;
|
||||||
|
|
||||||
|
private String maxValue;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
private String nullable;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.securitycontrol.inter.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceInfo {
|
||||||
|
/**
|
||||||
|
* 基础信息
|
||||||
|
*/
|
||||||
|
public List<PropertiesVo> staticProperties;
|
||||||
|
/**
|
||||||
|
* 采集信息
|
||||||
|
*/
|
||||||
|
public List<DetailsVo> dynamicProperties;
|
||||||
|
/**
|
||||||
|
* 预警信息
|
||||||
|
*/
|
||||||
|
private List<IsWarnVo> events;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -36,6 +36,10 @@ public class DeviceInfoVo {
|
||||||
private String data;
|
private String data;
|
||||||
|
|
||||||
private String dataTime;
|
private String dataTime;
|
||||||
|
/**
|
||||||
|
* 是否告警
|
||||||
|
*/
|
||||||
|
private String isWarn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.securitycontrol.inter.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史数据实体类
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class HisDeviceValueVo {
|
||||||
|
|
||||||
|
public String id;
|
||||||
|
|
||||||
|
public String bidCode;
|
||||||
|
|
||||||
|
public String attributeId;
|
||||||
|
|
||||||
|
public String val;
|
||||||
|
|
||||||
|
public String createTime;
|
||||||
|
|
||||||
|
public String isWarn;
|
||||||
|
|
||||||
|
public String sourceType;
|
||||||
|
|
||||||
|
public String sourceData;
|
||||||
|
|
||||||
|
public String changeVal;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.securitycontrol.inter.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class IsWarnVo {
|
||||||
|
|
||||||
|
private String descL;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.securitycontrol.inter.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PropertiesVo {
|
||||||
|
|
||||||
|
|
||||||
|
public String dataType;
|
||||||
|
|
||||||
|
public String desc;
|
||||||
|
|
||||||
|
public String id;
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.securitycontrol.inter.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据封装
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SelectDataVo {
|
||||||
|
/**
|
||||||
|
* 标段工程编码
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标段工程编码
|
||||||
|
*/
|
||||||
|
private String bidCode;
|
||||||
|
/**
|
||||||
|
* 设备id
|
||||||
|
*/
|
||||||
|
private String deviceId;
|
||||||
|
/**
|
||||||
|
* 属性id
|
||||||
|
*/
|
||||||
|
private String attributeId;
|
||||||
|
/**
|
||||||
|
* 历史值
|
||||||
|
*/
|
||||||
|
private String historyValue;
|
||||||
|
/**
|
||||||
|
* 单位
|
||||||
|
*/
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -设备编码现场
|
||||||
|
*/
|
||||||
|
private String deviceCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -检测数据编码
|
||||||
|
*/
|
||||||
|
private String attributeCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据类型
|
||||||
|
*/
|
||||||
|
private String dataType;
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
|
private String value;
|
||||||
|
/**
|
||||||
|
* 变化值
|
||||||
|
*/
|
||||||
|
private String changeValue;
|
||||||
|
/**
|
||||||
|
* 数据源
|
||||||
|
*/
|
||||||
|
private String sourceData;
|
||||||
|
|
||||||
|
private String isWarn;
|
||||||
|
|
||||||
|
|
||||||
|
private String dataTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -11,8 +11,19 @@
|
||||||
insert into tb_warn (warn_time,warn_content,warn_type,bd_device,db_id,bid_code)
|
insert into tb_warn (warn_time,warn_content,warn_type,bd_device,db_id,bid_code)
|
||||||
value (#{eventTime},#{eventDesc},#{eventCode},#{deviceId},#{gatewayId},#{bidCode})
|
value (#{eventTime},#{eventDesc},#{eventCode},#{deviceId},#{gatewayId},#{bidCode})
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="insertValue">
|
||||||
|
replace into tb_device_value (attribute_id,val,create_time,is_warn,unit,change_val)
|
||||||
|
value(#{attributeId},#{value},#{dataTime},#{isWarn},#{unit},#{changeValue})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertHistoryValue">
|
||||||
|
insert into(id, bid_code, attribute_id, val, create_time, is_warn, source_type,
|
||||||
|
source_data, change_val, unit)
|
||||||
|
values( #{id}, #{bidCode}, #{attributeId}, #{value}, #{dataTime}, #{isWarn},'边带数据上传',
|
||||||
|
#{sourceData},#{changeValue},#{unit}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
<update id="bindBdPro">
|
<update id="bindBdPro">
|
||||||
update tb_pro_bd set bid_code=#{bidNo},bind_time=now() where bd_code=#{gatewayId} ;
|
update tb_pro_bd set bid_code=#{bidNo},bind_time=now() where bd_code=#{gatewayId};
|
||||||
</update>
|
</update>
|
||||||
<update id="deviceDel">
|
<update id="deviceDel">
|
||||||
update tb_bd_device set del_flag=1 where device_id=#{deviceId} and bd_id=#{gatewayId}
|
update tb_bd_device set del_flag=1 where device_id=#{deviceId} and bd_id=#{gatewayId}
|
||||||
|
|
@ -88,4 +99,21 @@
|
||||||
from tb_pro_bd
|
from tb_pro_bd
|
||||||
where bd_code=#{gatewayId}
|
where bd_code=#{gatewayId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getDevCodeById" resultType="java.lang.String">
|
||||||
|
select dev_code
|
||||||
|
from tb_db_dev_rel_mapping
|
||||||
|
where device_id=#{deviceId}
|
||||||
|
</select>
|
||||||
|
<!--查询检测值信息-->
|
||||||
|
<select id="getBdDeviceDetailByIdCode" resultType="com.securitycontrol.inter.vo.SelectDataVo">
|
||||||
|
select tdd.id attributeId,tbd.device_id deviceId,tdv.unit,tdv.val historyValue,tpb.bid_code bidCode
|
||||||
|
,tbd.bd_code deviceCode,tdd.device_code attributeCode,tdd.data_type dataType
|
||||||
|
from tb_bd_device tbd
|
||||||
|
left join tb_pro_bd tpb on tpb.id=tbd.bd_id
|
||||||
|
left join tb_device_detail tdd on tdd.device_id=tbd.device_id
|
||||||
|
left JOIN tb_device_value tdv on tdv.attribute_id=tdd.id
|
||||||
|
where tbd.bd_code=#{id} and tdd.device_code=#{code}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue