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