[1078] 通用通道支持位置更新
This commit is contained in:
@@ -583,4 +583,18 @@ public interface CommonGBChannelMapper {
|
||||
|
||||
@Update("UPDATE wvp_device_channel SET stream_id = #{stream} where id = #{gbId}")
|
||||
void updateStream(int gbId, String stream);
|
||||
|
||||
@Update("<script> " +
|
||||
"<foreach collection='commonGBChannels' index='index' item='item' separator=';'> " +
|
||||
"UPDATE wvp_device_channel " +
|
||||
" SET gb_longitude=#{item.gbLongitude}" +
|
||||
", gb_latitude=#{item.gbLatitude} " +
|
||||
", gps_speed=#{item.gpsSpeed} " +
|
||||
", gps_altitude=#{item.gpsAltitude} " +
|
||||
", gps_direction=#{item.gpsDirection} " +
|
||||
", gps_time=#{item.gpsTime} " +
|
||||
"WHERE id = #{item.gbId}" +
|
||||
"</foreach> " +
|
||||
"</script>")
|
||||
void updateGps(List<CommonGBChannel> commonGBChannels);
|
||||
}
|
||||
|
||||
@@ -96,4 +96,5 @@ public interface IGbChannelService {
|
||||
|
||||
void updateGPSFromGPSMsgInfo(List<GPSMsgInfo> gpsMsgInfoList);
|
||||
|
||||
void updateGPS(List<CommonGBChannel> channelList);
|
||||
}
|
||||
|
||||
@@ -771,4 +771,21 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
}
|
||||
commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void updateGPS(List<CommonGBChannel> commonGBChannels) {
|
||||
int limitCount = 1000;
|
||||
if (commonGBChannels.size() > limitCount) {
|
||||
for (int i = 0; i < commonGBChannels.size(); i += limitCount) {
|
||||
int toIndex = i + limitCount;
|
||||
if (i + limitCount > commonGBChannels.size()) {
|
||||
toIndex = commonGBChannels.size();
|
||||
}
|
||||
commonGBChannelMapper.updateGps(commonGBChannels.subList(i, toIndex));
|
||||
}
|
||||
} else {
|
||||
commonGBChannelMapper.updateGps(commonGBChannels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,44 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
@Async("taskExecutor")
|
||||
@EventListener
|
||||
public void onApplicationEvent(JTPositionEvent event) {
|
||||
if (event.getPhoneNumber() == null || event.getPositionInfo() == null
|
||||
|| event.getPositionInfo().getLongitude() == null || event.getPositionInfo().getLatitude() == null) {
|
||||
return;
|
||||
}
|
||||
JTDevice device = getDevice(event.getPhoneNumber());
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
device.setLongitude(event.getPositionInfo().getLongitude());
|
||||
device.setLatitude(event.getPositionInfo().getLatitude());
|
||||
updateDevice(device);
|
||||
|
||||
// 通道发送状态变化通知
|
||||
List<JTChannel> jtChannels = jtChannelMapper.selectAll(device.getId(), null);
|
||||
List<CommonGBChannel> channelList = new ArrayList<>();
|
||||
for (JTChannel jtChannel : jtChannels) {
|
||||
if (jtChannel.getGbId() > 0) {
|
||||
jtChannel.setGbLongitude(event.getPositionInfo().getLongitude());
|
||||
jtChannel.setGbLatitude(event.getPositionInfo().getLatitude());
|
||||
if (event.getPositionInfo().getAltitude() != null) {
|
||||
jtChannel.setGpsAltitude((double) event.getPositionInfo().getAltitude());
|
||||
}else {
|
||||
jtChannel.setGpsAltitude(0d);
|
||||
}
|
||||
if (event.getPositionInfo().getDirection() != null) {
|
||||
jtChannel.setGpsDirection((double) event.getPositionInfo().getDirection());
|
||||
}else {
|
||||
jtChannel.setGpsDirection(0d);
|
||||
}
|
||||
if (event.getPositionInfo().getTime() != null) {
|
||||
jtChannel.setGpsTime(event.getPositionInfo().getTime());
|
||||
}else {
|
||||
jtChannel.setGpsTime(DateUtil.getNow());
|
||||
}
|
||||
channelList.add(jtChannel);
|
||||
}
|
||||
}
|
||||
channelService.updateGPS(channelList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user