提高注册兼容性, 修复sql兼容mysql
This commit is contained in:
@@ -19,12 +19,12 @@ public interface DeviceChannelMapper {
|
||||
"ipAddress, port, password, PTZType, status, streamId, longitude, latitude, createTime, updateTime) " +
|
||||
"VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
|
||||
"'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
|
||||
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude}, datetime('now','localtime'), datetime('now','localtime'))")
|
||||
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude},'${createTime}', '${updateTime}')")
|
||||
int add(DeviceChannel channel);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE device_channel " +
|
||||
"SET updateTime=datetime('now','localtime')" +
|
||||
"SET updateTime='${updateTime}'" +
|
||||
"<if test=\"name != null\">, name='${name}'</if>" +
|
||||
"<if test=\"manufacture != null\">, manufacture='${manufacture}'</if>" +
|
||||
"<if test=\"model != null\">, model='${model}'</if>" +
|
||||
|
||||
@@ -47,15 +47,15 @@ public interface DeviceMapper {
|
||||
"#{expires}," +
|
||||
"#{registerTime}," +
|
||||
"#{keepaliveTime}," +
|
||||
"datetime('now','localtime')," +
|
||||
"datetime('now','localtime')," +
|
||||
"#{createTime}," +
|
||||
"#{updateTime}," +
|
||||
"#{online}" +
|
||||
")")
|
||||
int add(Device device);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE device " +
|
||||
"SET updateTime=datetime('now','localtime')" +
|
||||
"SET updateTime='${updateTime}'" +
|
||||
"<if test=\"name != null\">, name='${name}'</if>" +
|
||||
"<if test=\"manufacturer != null\">, manufacturer='${manufacturer}'</if>" +
|
||||
"<if test=\"model != null\">, model='${model}'</if>" +
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.storager.impl;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
@@ -70,6 +71,8 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
@Autowired
|
||||
private VideoStreamSessionManager streamSession;
|
||||
|
||||
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备ID判断设备是否存在
|
||||
@@ -103,8 +106,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateDevice(Device device) {
|
||||
String now = this.format.format(new Date(System.currentTimeMillis()));
|
||||
device.setUpdateTime(now);
|
||||
Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
|
||||
if (deviceByDeviceId == null) {
|
||||
device.setCreateTime(now);
|
||||
return deviceMapper.add(device) > 0;
|
||||
}else {
|
||||
return deviceMapper.update(device) > 0;
|
||||
@@ -117,8 +123,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
String channelId = channel.getChannelId();
|
||||
channel.setDeviceId(deviceId);
|
||||
channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
|
||||
String now = this.format.format(new Date(System.currentTimeMillis()));
|
||||
channel.setUpdateTime(now);
|
||||
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
|
||||
if (deviceChannel == null) {
|
||||
channel.setCreateTime(now);
|
||||
deviceChannelMapper.add(channel);
|
||||
}else {
|
||||
deviceChannelMapper.update(channel);
|
||||
|
||||
Reference in New Issue
Block a user