数据库优化
This commit is contained in:
@@ -15,8 +15,8 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface DeviceAlarmMapper {
|
||||
|
||||
@Insert("INSERT INTO device_alarm (deviceId, channelId, alarmPriority, alarmMethod, alarmTime, alarmDescription, longitude, latitude, alarmType ) " +
|
||||
"VALUES ('${deviceId}', '${channelId}', '${alarmPriority}', '${alarmMethod}', '${alarmTime}', '${alarmDescription}', ${longitude}, ${latitude}, '${alarmType}')")
|
||||
@Insert("INSERT INTO device_alarm (deviceId, channelId, alarmPriority, alarmMethod, alarmTime, alarmDescription, longitude, latitude, alarmType , createTime ) " +
|
||||
"VALUES ('${deviceId}', '${channelId}', '${alarmPriority}', '${alarmMethod}', '${alarmTime}', '${alarmDescription}', ${longitude}, ${latitude}, '${alarmType}', '${createTime}')")
|
||||
int add(DeviceAlarm alarm);
|
||||
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ public interface DeviceChannelMapper {
|
||||
@Insert("INSERT INTO device_channel (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, longitudeGcj02, latitudeGcj02, " +
|
||||
"longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId) " +
|
||||
"longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId, gpsTime) " +
|
||||
"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}, ${longitudeGcj02}, " +
|
||||
"${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84},'${createTime}', '${updateTime}', '${businessGroupId}')")
|
||||
"${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84},'${createTime}', '${updateTime}', '${businessGroupId}', '${gpsTime}')")
|
||||
int add(DeviceChannel channel);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
@@ -58,6 +58,7 @@ public interface DeviceChannelMapper {
|
||||
"<if test='longitudeWgs84 != null'>, longitudeWgs84=${longitudeWgs84}</if>" +
|
||||
"<if test='latitudeWgs84 != null'>, latitudeWgs84=${latitudeWgs84}</if>" +
|
||||
"<if test='businessGroupId != null'>, businessGroupId=#{businessGroupId}</if>" +
|
||||
"<if test='gpsTime != null'>, gpsTime=#{gpsTime}</if>" +
|
||||
"WHERE deviceId='${deviceId}' AND channelId='${channelId}'"+
|
||||
" </script>"})
|
||||
int update(DeviceChannel channel);
|
||||
@@ -147,7 +148,7 @@ public interface DeviceChannelMapper {
|
||||
"(channelId, deviceId, name, manufacture, model, owner, civilCode, block, subCount, " +
|
||||
" address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
|
||||
" ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
|
||||
" longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId) " +
|
||||
" longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId, gpsTime) " +
|
||||
"values " +
|
||||
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
|
||||
"('${item.channelId}', '${item.deviceId}', '${item.name}', '${item.manufacture}', '${item.model}', " +
|
||||
@@ -157,7 +158,7 @@ public interface DeviceChannelMapper {
|
||||
"'${item.ipAddress}', ${item.port}, '${item.password}', ${item.PTZType}, ${item.status}, " +
|
||||
"'${item.streamId}', ${item.longitude}, ${item.latitude},${item.longitudeGcj02}, " +
|
||||
"${item.latitudeGcj02},${item.longitudeWgs84}, ${item.latitudeWgs84},'${item.createTime}', '${item.updateTime}', " +
|
||||
"'${item.businessGroupId}') " +
|
||||
"'${item.businessGroupId}', '${item.gpsTime}') " +
|
||||
"</foreach> " +
|
||||
"ON DUPLICATE KEY UPDATE " +
|
||||
"updateTime=VALUES(updateTime), " +
|
||||
@@ -189,7 +190,8 @@ public interface DeviceChannelMapper {
|
||||
"latitudeGcj02=VALUES(latitudeGcj02), " +
|
||||
"longitudeWgs84=VALUES(longitudeWgs84), " +
|
||||
"latitudeWgs84=VALUES(latitudeWgs84), " +
|
||||
"businessGroupId=VALUES(businessGroupId) " +
|
||||
"businessGroupId=VALUES(businessGroupId), " +
|
||||
"gpsTime=VALUES(gpsTime)" +
|
||||
"</script>")
|
||||
int batchAdd(List<DeviceChannel> addChannels);
|
||||
|
||||
@@ -228,6 +230,7 @@ public interface DeviceChannelMapper {
|
||||
"<if test='item.longitudeWgs84 != null'>, longitudeWgs84=${item.longitudeWgs84}</if>" +
|
||||
"<if test='item.latitudeWgs84 != null'>, latitudeWgs84=${item.latitudeWgs84}</if>" +
|
||||
"<if test='item.businessGroupId != null'>, businessGroupId=#{item.businessGroupId}</if>" +
|
||||
"<if test='item.gpsTime != null'>, gpsTime=#{item.gpsTime}</if>" +
|
||||
"WHERE deviceId='${item.deviceId}' AND channelId='${item.channelId}'"+
|
||||
"</foreach>" +
|
||||
"</script>"})
|
||||
@@ -281,10 +284,11 @@ public interface DeviceChannelMapper {
|
||||
"SET " +
|
||||
"latitude=${latitude}, " +
|
||||
"longitude=${longitude}, " +
|
||||
"longitudeGcj02=${longitudeGcj02}," +
|
||||
"latitudeGcj02=${latitudeGcj02}," +
|
||||
"longitudeWgs84=${longitudeWgs84}," +
|
||||
"latitudeWgs84=${latitudeWgs84} " +
|
||||
"longitudeGcj02=${longitudeGcj02}, " +
|
||||
"latitudeGcj02=${latitudeGcj02}, " +
|
||||
"longitudeWgs84=${longitudeWgs84}, " +
|
||||
"latitudeWgs84=${latitudeWgs84}, " +
|
||||
"gpsTime='${gpsTime}' " +
|
||||
"WHERE deviceId=#{deviceId} " +
|
||||
" <if test='channelId != null' > AND channelId=#{channelId}</if>" +
|
||||
" </script>"})
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.apache.ibatis.annotations.*;
|
||||
@Mapper
|
||||
public interface DeviceMobilePositionMapper {
|
||||
|
||||
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84) " +
|
||||
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', ${longitudeGcj02}, ${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84})")
|
||||
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84, createTime) " +
|
||||
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', ${longitudeGcj02}, ${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84}, '${createTime}')")
|
||||
int insertNewPosition(MobilePosition mobilePosition);
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
|
||||
@@ -15,10 +15,10 @@ import java.util.List;
|
||||
public interface GbStreamMapper {
|
||||
|
||||
@Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " +
|
||||
"longitude, latitude, streamType, mediaServerId, status, createStamp) VALUES" +
|
||||
"longitude, latitude, streamType, mediaServerId, status, createTime) VALUES" +
|
||||
"('${app}', '${stream}', '${gbId}', '${name}', " +
|
||||
"'${longitude}', '${latitude}', '${streamType}', " +
|
||||
"'${mediaServerId}', ${status}, ${createStamp})")
|
||||
"'${mediaServerId}', ${status}, '${createTime}')")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
|
||||
int add(GbStream gbStream);
|
||||
|
||||
@@ -120,12 +120,12 @@ public interface GbStreamMapper {
|
||||
@Insert("<script> " +
|
||||
"INSERT IGNORE into gb_stream " +
|
||||
"(app, stream, gbId, name, " +
|
||||
"longitude, latitude, streamType, mediaServerId, status, createStamp)" +
|
||||
"longitude, latitude, streamType, mediaServerId, status, createTime)" +
|
||||
"values " +
|
||||
"<foreach collection='subList' index='index' item='item' separator=','> " +
|
||||
"('${item.app}', '${item.stream}', '${item.gbId}', '${item.name}', " +
|
||||
"'${item.longitude}', '${item.latitude}', '${item.streamType}', " +
|
||||
"'${item.mediaServerId}', ${item.status}, ${item.createStamp}) "+
|
||||
"'${item.mediaServerId}', ${item.status}, '${item.createTime}') "+
|
||||
"</foreach> " +
|
||||
"</script>")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
|
||||
|
||||
@@ -16,10 +16,10 @@ public interface ParentPlatformMapper {
|
||||
|
||||
@Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
|
||||
" devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
|
||||
" status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup) " +
|
||||
" status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime) " +
|
||||
" VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
|
||||
" '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
|
||||
" ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup})")
|
||||
" ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime})")
|
||||
int addParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
@Update("UPDATE parent_platform " +
|
||||
@@ -45,6 +45,8 @@ public interface ParentPlatformMapper {
|
||||
"startOfflinePush=${startOfflinePush}, " +
|
||||
"catalogGroup=#{catalogGroup}, " +
|
||||
"administrativeDivision=#{administrativeDivision}, " +
|
||||
"createTime=#{createTime}, " +
|
||||
"updateTime=#{updateTime}, " +
|
||||
"catalogId=#{catalogId} " +
|
||||
"WHERE id=#{id}")
|
||||
int updateParentPlatform(ParentPlatform parentPlatform);
|
||||
@@ -86,10 +88,10 @@ public interface ParentPlatformMapper {
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE parent_platform " +
|
||||
"SET catalogId=#{catalogId}" +
|
||||
"SET catalogId=#{catalogId}, updateTime=#{updateTime}" +
|
||||
"WHERE serverGBId=#{platformId}"+
|
||||
"</script>"})
|
||||
int setDefaultCatalog(String platformId, String catalogId);
|
||||
int setDefaultCatalog(String platformId, String catalogId, String updateTime);
|
||||
|
||||
@Select("select 'channel' as name, count(pgc.platformId) count from platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId where pgc.platformId=#{platformId} and dc.channelId =#{gbId} " +
|
||||
"union " +
|
||||
|
||||
@@ -714,7 +714,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
streamProxyItem.setStatus(true);
|
||||
String now = DateUtil.getNow();
|
||||
streamProxyItem.setCreateTime(now);
|
||||
streamProxyItem.setCreateStamp(System.currentTimeMillis());
|
||||
try {
|
||||
if (streamProxyMapper.add(streamProxyItem) > 0) {
|
||||
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
|
||||
@@ -1009,7 +1008,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
|
||||
@Override
|
||||
public int setDefaultCatalog(String platformId, String catalogId) {
|
||||
return platformMapper.setDefaultCatalog(platformId, catalogId);
|
||||
return platformMapper.setDefaultCatalog(platformId, catalogId, DateUtil.getNow());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1126,6 +1125,10 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) {
|
||||
deviceChannel.setChannelId(null);
|
||||
}
|
||||
if (deviceChannel.getGpsTime() == null) {
|
||||
deviceChannel.setGpsTime(DateUtil.getNow());
|
||||
}
|
||||
|
||||
deviceChannelMapper.updatePosition(deviceChannel);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user