TCP 服务端 告警入库
This commit is contained in:
parent
7eb9dfb23f
commit
c58bde1ae2
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.aqd.base.dao;
|
||||
|
||||
import com.bonus.aqd.base.entity.DevVO;
|
||||
import com.bonus.aqd.base.entity.vo.WarnInfoVo;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
|
|
@ -29,4 +30,9 @@ public interface DevDataMapper {
|
|||
*/
|
||||
void downDevStatus(DevVO devVO);
|
||||
|
||||
/**
|
||||
* 告警数据插入
|
||||
* @param warnInfoVo
|
||||
*/
|
||||
void insertWarnInfo(WarnInfoVo warnInfoVo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,14 +49,12 @@ public class IndexServiceImpl implements IndexService {
|
|||
List<DeviceInfoVo> list = new ArrayList<>();
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
|
||||
list = mapper.getDevicesInfo(dto);
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
list.forEach(vo->{
|
||||
try {
|
||||
if("1".equals(vo.getDevStatus())){
|
||||
Date date = sdf.parse("2024-07-31 09:20:30");
|
||||
if("1".equals(vo.getDevStatus().toString())){
|
||||
Date date = sdf.parse(vo.getStateTime());
|
||||
String time =getDatePoor(date);
|
||||
vo.setOnlineTime(time);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bonus.aqd.base.dao.IndexMapper;
|
|||
import com.bonus.aqd.base.entity.DevVO;
|
||||
import com.bonus.aqd.base.entity.dto.ParamsDto;
|
||||
import com.bonus.aqd.base.entity.vo.DeviceInfoVo;
|
||||
import com.bonus.aqd.base.entity.vo.WarnInfoVo;
|
||||
import com.bonus.aqd.manager.common.util.DateTimeHelper;
|
||||
import com.bonus.aqd.manager.common.util.StringHelper;
|
||||
import com.bonus.aqd.manager.core.dao.SysUserDao;
|
||||
|
|
@ -111,6 +112,7 @@ public class SaveDataService {
|
|||
//传输类型
|
||||
// Integer direction = Integer.parseInt(msg.substring(10, 12), 16);
|
||||
Integer warn = Integer.parseInt(msg.substring(12, 14), 16);
|
||||
|
||||
DevVO VO = new DevVO();
|
||||
VO.setDevCode(devCode);
|
||||
VO.setWarnInfo(warn.toString());
|
||||
|
|
@ -119,7 +121,9 @@ public class SaveDataService {
|
|||
VO.setDevB("1");
|
||||
mapper.updateData(VO);
|
||||
} else if (type == 17) {
|
||||
WarnInfoVo warnInfoVo=new WarnInfoVo();
|
||||
String time=DateTimeHelper.getNowTime();
|
||||
warnInfoVo.setDevCode(devCode);
|
||||
if (warn == 0) {
|
||||
VO.setDevA("1");
|
||||
VO.setDevB("1");
|
||||
|
|
@ -127,15 +131,25 @@ public class SaveDataService {
|
|||
VO.setDevA("0");
|
||||
VO.setDevB("1");
|
||||
VO.setDevAtime(time);
|
||||
warnInfoVo.setWarnContent("A钩脱落");
|
||||
warnInfoVo.setWarnReason("单钩-A钩脱落");
|
||||
warnInfoVo.setDevModule("单钩");
|
||||
} else if (warn == 2) {
|
||||
VO.setDevA("1");
|
||||
VO.setDevB("0");
|
||||
VO.setDevBtime(time);
|
||||
warnInfoVo.setWarnContent("B钩脱落");
|
||||
warnInfoVo.setWarnReason("单钩-B钩脱落");
|
||||
warnInfoVo.setDevModule("单钩");
|
||||
} else if (warn == 3) {
|
||||
VO.setDevA("0");
|
||||
VO.setDevB("0");
|
||||
VO.setDevAtime(time);
|
||||
VO.setDevBtime(time);
|
||||
warnInfoVo.setWarnContent("双钩脱落");
|
||||
warnInfoVo.setWarnReason("双钩-双钩脱落");
|
||||
warnInfoVo.setDevModule("双钩");
|
||||
mapper.insertWarnInfo(warnInfoVo);
|
||||
}
|
||||
mapper.updateData(VO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.aqd.base.dao.DevDataMapper">
|
||||
<insert id="insertWarnInfo">
|
||||
insert into tb_warn (
|
||||
dev_code, warn_content,
|
||||
warn_time,warn_reason, dev_module
|
||||
)values (#{devCode} ,#{warnContent},now(),#{warnReason},#{devModule})
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="updateData" parameterType="com.bonus.aqd.base.entity.DevVO">
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
dev_code AS devCode,
|
||||
dev_modu AS devModu,
|
||||
puid,
|
||||
warn_info
|
||||
warn_info warnInfo
|
||||
FROM tb_device WHERE id = #{id}
|
||||
</select>
|
||||
<!--查询设备状态数量-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue