mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-25 22:47:49 +08:00
1078-增加位置信息并发处理能力
This commit is contained in:
parent
93532a6b3b
commit
36e15c80b0
@ -181,6 +181,7 @@ public class VideoManagerConstants {
|
|||||||
//************************** 1078 ****************************************
|
//************************** 1078 ****************************************
|
||||||
|
|
||||||
|
|
||||||
|
public static final String INVITE_INFO_1078_POSITION = "INVITE_INFO_1078_POSITION:";
|
||||||
public static final String INVITE_INFO_1078_PLAY = "INVITE_INFO_1078_PLAY:";
|
public static final String INVITE_INFO_1078_PLAY = "INVITE_INFO_1078_PLAY:";
|
||||||
public static final String INVITE_INFO_1078_PLAYBACK = "INVITE_INFO_1078_PLAYBACK:";
|
public static final String INVITE_INFO_1078_PLAYBACK = "INVITE_INFO_1078_PLAYBACK:";
|
||||||
public static final String INVITE_INFO_1078_TALK = "INVITE_INFO_1078_TALK:";
|
public static final String INVITE_INFO_1078_TALK = "INVITE_INFO_1078_TALK:";
|
||||||
|
|||||||
@ -103,4 +103,16 @@ public interface JTTerminalMapper {
|
|||||||
@Select("SELECT * FROM wvp_jt_terminal where id=#{deviceId}")
|
@Select("SELECT * FROM wvp_jt_terminal where id=#{deviceId}")
|
||||||
JTDevice getDeviceById(@Param("deviceId") Integer deviceId);
|
JTDevice getDeviceById(@Param("deviceId") Integer deviceId);
|
||||||
|
|
||||||
|
@Update({"<script>" +
|
||||||
|
"<foreach collection='devices' item='item' separator=';'>" +
|
||||||
|
" UPDATE" +
|
||||||
|
" wvp_jt_terminal" +
|
||||||
|
" SET update_time=#{item.updateTime}" +
|
||||||
|
"<if test='item.longitude != null'>, longitude=#{item.longitude}</if>" +
|
||||||
|
"<if test='item.latitude != null'>, latitude=#{item.latitude}</if>" +
|
||||||
|
"<if test='item.id > 0'>WHERE id=#{item.id}</if>" +
|
||||||
|
"<if test='item.id == 0 and item.phoneNumber != null '>WHERE phone_number=#{item.phoneNumber}</if>" +
|
||||||
|
"</foreach>" +
|
||||||
|
"</script>"})
|
||||||
|
void batchUpdateDevicePosition(List<JTDevice> devices);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,19 +89,11 @@ public class J0200 extends Re {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
||||||
JTDevice deviceInDb = service.getDevice(header.getPhoneNumber());
|
|
||||||
J8001 j8001 = new J8001();
|
J8001 j8001 = new J8001();
|
||||||
j8001.setRespNo(header.getSn());
|
j8001.setRespNo(header.getSn());
|
||||||
j8001.setRespId(header.getMsgId());
|
j8001.setRespId(header.getMsgId());
|
||||||
if (deviceInDb == null) {
|
j8001.setResult(J8001.SUCCESS);
|
||||||
j8001.setResult(J8001.FAIL);
|
service.updateDevicePosition(header.getPhoneNumber(), positionInfo.getLongitude(), positionInfo.getLatitude());
|
||||||
}else {
|
|
||||||
// TODO 优化为发送异步事件,定时读取队列写入数据库
|
|
||||||
deviceInDb.setLongitude(positionInfo.getLongitude());
|
|
||||||
deviceInDb.setLatitude(positionInfo.getLatitude());
|
|
||||||
service.updateDevice(deviceInDb);
|
|
||||||
j8001.setResult(J8001.SUCCESS);
|
|
||||||
}
|
|
||||||
return j8001;
|
return j8001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -132,4 +132,5 @@ public interface Ijt1078Service {
|
|||||||
|
|
||||||
JTDevice getDeviceById(Integer deviceId);
|
JTDevice getDeviceById(Integer deviceId);
|
||||||
|
|
||||||
|
void updateDevicePosition(String phoneNumber, Double longitude, Double latitude);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -1158,4 +1160,32 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
public JTDevice getDeviceById(Integer deviceId) {
|
public JTDevice getDeviceById(Integer deviceId) {
|
||||||
return jtDeviceMapper.getDeviceById(deviceId);
|
return jtDeviceMapper.getDeviceById(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDevicePosition(String phoneNumber, Double longitude, Double latitude) {
|
||||||
|
JTDevice device = new JTDevice();
|
||||||
|
device.setPhoneNumber(phoneNumber);
|
||||||
|
device.setLongitude(longitude);
|
||||||
|
device.setLatitude(latitude);
|
||||||
|
device.setUpdateTime(DateUtil.getNow());
|
||||||
|
String key = VideoManagerConstants.INVITE_INFO_1078_POSITION + userSetting.getServerId();
|
||||||
|
redisTemplate.opsForList().leftPush(key, device);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(fixedDelay = 1000)
|
||||||
|
public void positionTask(){
|
||||||
|
String key = VideoManagerConstants.INVITE_INFO_1078_POSITION + userSetting.getServerId();
|
||||||
|
int count = 1000;
|
||||||
|
List<JTDevice> devices = new ArrayList<>(count);
|
||||||
|
Long size = redisTemplate.opsForList().size(key);
|
||||||
|
if (size == null || size == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long readCount = Math.min(count, size);
|
||||||
|
for (long i = 0L; i < readCount; i++) {
|
||||||
|
devices.add((JTDevice)redisTemplate.opsForList().rightPop(key));
|
||||||
|
}
|
||||||
|
jtDeviceMapper.batchUpdateDevicePosition(devices);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,11 @@ export default {
|
|||||||
},
|
},
|
||||||
onSubmit: function () {
|
onSubmit: function () {
|
||||||
console.log("onSubmit");
|
console.log("onSubmit");
|
||||||
let params = this.form
|
let params = {
|
||||||
|
channelId: this.form.channelId,
|
||||||
|
name: this.form.name,
|
||||||
|
terminalDbId: this.deviceId,
|
||||||
|
}
|
||||||
this.$axios({
|
this.$axios({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url:`/api/jt1078/terminal/channel/${this.isEdit?'update':'add'}/`,
|
url:`/api/jt1078/terminal/channel/${this.isEdit?'update':'add'}/`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user