netty-修改请求框架,并且注册客户端信息落地,之后通过调用netty接口来进行后续操作。
This commit is contained in:
@@ -62,4 +62,18 @@ public interface DeviceMapper {
|
||||
List<DeviceDTO> findAllDTO();
|
||||
|
||||
Integer countByStream(@Param("stream") String stream,@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 更新设备状态为 0 - 未连接
|
||||
*/
|
||||
void offline(@Param("venueId") Integer venueId,@Param("deviceName") String deviceName);
|
||||
|
||||
/**
|
||||
* 更新设备状态为 2 - 连接成功
|
||||
*/
|
||||
void online(@Param("venueId") Integer venueId,@Param("deviceName") String deviceName);
|
||||
|
||||
|
||||
Integer checkDevice(@Param("deviceName") String deviceName,@Param("venueId") Integer venueId);
|
||||
|
||||
}
|
||||
@@ -20,6 +20,8 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -29,7 +31,6 @@ import java.util.List;
|
||||
* @since 2018-08-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class DeviceService extends BaseServiceImpl {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(DeviceService.class);
|
||||
@@ -131,26 +132,30 @@ public class DeviceService extends BaseServiceImpl {
|
||||
|
||||
/**
|
||||
* 设备连接断开
|
||||
* @param deviceId
|
||||
*/
|
||||
@Transactional
|
||||
public void offline(Integer deviceId){
|
||||
Device device = new Device();
|
||||
device.setId(deviceId);
|
||||
device.setStatus(DeviceStatusEnum.OFFLINE.value);
|
||||
deviceMapper.update(device);
|
||||
public void offline(String deviceName, Integer venueId){
|
||||
deviceMapper.offline(venueId,deviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备连接成功
|
||||
* @param deviceId
|
||||
* 新的设备注册的逻辑
|
||||
*/
|
||||
@Transactional
|
||||
public void online(Integer deviceId){
|
||||
Device device = new Device();
|
||||
device.setId(deviceId);
|
||||
device.setStatus(DeviceStatusEnum.ONLINE.value);
|
||||
deviceMapper.update(device);
|
||||
public void online(String deviceName,Integer venueId,Integer venueType,String deviceIp){
|
||||
Device device = new Device();
|
||||
device.setVenueId(venueId);
|
||||
device.setVenueType(venueType);
|
||||
device.setName(deviceName);
|
||||
device.setStatus(DeviceStatusEnum.ONLINE.value);
|
||||
device.setStream(deviceIp);
|
||||
if(deviceMapper.checkDevice(deviceName,venueId) > 0){
|
||||
logger.info(deviceName + venueId + "设备已存在,该设备。");
|
||||
deviceMapper.online(venueId, deviceName);
|
||||
}else {
|
||||
logger.info("落地客户端信息clientId = " + deviceIp + "&deviceName = " + deviceName + "&venueId = " + venueId);
|
||||
deviceMapper.insert(device);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user