临时提交
This commit is contained in:
@@ -614,7 +614,7 @@ public interface CommonGBChannelMapper {
|
||||
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryGbChannelByChannelDeviceIdAndGbDeviceId")
|
||||
CameraChannel queryGbChannelByChannelDeviceIdAndGbDeviceId(@Param("channelDeviceId") String channelDeviceId, @Param("gbDeviceId") String gbDeviceId);
|
||||
List<CameraChannel> queryGbChannelByChannelDeviceIdAndGbDeviceId(@Param("channelDeviceId") String channelDeviceId, @Param("gbDeviceId") String gbDeviceId);
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryListByDeviceIds")
|
||||
List<CameraChannel> queryListByDeviceIds(List<String> deviceIds);
|
||||
@@ -659,4 +659,6 @@ public interface CommonGBChannelMapper {
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryCameraChannelByIds")
|
||||
List<CameraChannel> queryCameraChannelByIds(List<Integer> ids);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -309,13 +309,14 @@ public interface GroupMapper {
|
||||
|
||||
@Select(" <script>" +
|
||||
" SELECT " +
|
||||
" coalesce( wdc.gb_parent_id, wdc.parent_id) as deviceId," +
|
||||
" ANY_VALUE(coalesce( wdc.gb_parent_id, wdc.parent_id)) as deviceId," +
|
||||
" COUNT(*) AS allCount," +
|
||||
" SUM(CASE WHEN coalesce( wdc.gb_status, wdc.status) = 'ON' THEN 1 ELSE 0 END) AS onlineCount" +
|
||||
" FROM " +
|
||||
" wvp_device_channel wdc " +
|
||||
" where coalesce( wdc.gb_parent_id, wdc.parent_id) in " +
|
||||
" <foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
|
||||
" GROUP BY coalesce(wdc.gb_parent_id, wdc.parent_id)" +
|
||||
"</script>")
|
||||
List<CameraCount> queryCountWithChild(List<CameraGroup> groupList);
|
||||
}
|
||||
|
||||
@@ -216,10 +216,6 @@ public class ChannelProvider {
|
||||
return BASE_SQL + " where channel_type = 0 and data_type = #{dataType} and data_device_id = #{dataDeviceId}";
|
||||
}
|
||||
|
||||
public String queryCameraChannelById(Map<String, Object> params ){
|
||||
return BASE_SQL + " where id = #{gbId}";
|
||||
}
|
||||
|
||||
public String queryListByCivilCode(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(BASE_SQL);
|
||||
@@ -548,12 +544,12 @@ public class ChannelProvider {
|
||||
public String queryListForSy(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(BASE_SQL_FOR_CAMERA_DEVICE);
|
||||
sqlBuild.append(" where wdc.channel_type = 0 AND (wdc.gb_ptz_type is null || wdc.gb_ptz_type != 99) AND coalesce(gb_parent_id, parent_id) = #{groupDeviceId}");
|
||||
sqlBuild.append(" where wdc.channel_type = 0 AND (wdc.gb_ptz_type is null || wdc.gb_ptz_type != 99) AND coalesce(wdc.gb_parent_id, wdc.parent_id) = #{groupDeviceId}");
|
||||
if (params.get("online") != null && (Boolean)params.get("online")) {
|
||||
sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'");
|
||||
sqlBuild.append(" AND coalesce(wdc.gb_status, wdc.status) = 'ON'");
|
||||
}
|
||||
if (params.get("online") != null && !(Boolean)params.get("online")) {
|
||||
sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'");
|
||||
sqlBuild.append(" AND coalesce(wdc.gb_status, wdc.status) = 'OFF'");
|
||||
}
|
||||
|
||||
return sqlBuild.toString();
|
||||
@@ -851,7 +847,17 @@ public class ChannelProvider {
|
||||
}
|
||||
|
||||
public String queryListForSyMobile(Map<String, Object> params ){
|
||||
return BASE_SQL_FOR_CAMERA_DEVICE +
|
||||
" WHERE wdc.gb_ptz_type = 99 AND coalesce(gb_business_group_id, business_group_id) = #{business}";
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(BASE_SQL_FOR_CAMERA_DEVICE);
|
||||
sqlBuild.append(" WHERE wdc.gb_ptz_type = 99 ");
|
||||
if (params.get("business") != null) {
|
||||
sqlBuild.append(" AND coalesce(gb_business_group_id, business_group_id) = #{business}");
|
||||
}
|
||||
return sqlBuild.toString();
|
||||
}
|
||||
|
||||
|
||||
public String queryCameraChannelById(Map<String, Object> params ){
|
||||
return BASE_SQL_FOR_CAMERA_DEVICE + " where wdc.id = #{gbId}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,16 @@ public class EventPublisher {
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
public void channelEventPublish(CommonGBChannel deviceChannel, ChannelEvent.ChannelEventMessageType type) {
|
||||
catalogEventPublish(Collections.singletonList(deviceChannel), type);
|
||||
public void channelEventPublish(CommonGBChannel commonGBChannel, ChannelEvent.ChannelEventMessageType type) {
|
||||
channelEventPublish(Collections.singletonList(commonGBChannel), type);
|
||||
}
|
||||
|
||||
private void catalogEventPublish(List<CommonGBChannel> channelList, ChannelEvent.ChannelEventMessageType type) {
|
||||
public void channelEventPublishForUpdate(CommonGBChannel commonGBChannel, CommonGBChannel deviceChannelForOld) {
|
||||
ChannelEvent channelEvent = ChannelEvent.getInstanceForUpdate(this, Collections.singletonList(commonGBChannel), Collections.singletonList(deviceChannelForOld));
|
||||
applicationEventPublisher.publishEvent(channelEvent);
|
||||
}
|
||||
|
||||
public void channelEventPublish(List<CommonGBChannel> channelList, ChannelEvent.ChannelEventMessageType type) {
|
||||
ChannelEvent channelEvent = ChannelEvent.getInstance(this, type, channelList);
|
||||
applicationEventPublisher.publishEvent(channelEvent);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import lombok.Setter;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,6 +25,8 @@ public class ChannelEvent extends ApplicationEvent {
|
||||
|
||||
private List<CommonGBChannel> channels;
|
||||
|
||||
private List<CommonGBChannel> oldChannels;
|
||||
|
||||
private ChannelEventMessageType messageType;
|
||||
|
||||
|
||||
@@ -41,4 +42,12 @@ public class ChannelEvent extends ApplicationEvent {
|
||||
return channelEvent;
|
||||
}
|
||||
|
||||
public static ChannelEvent getInstanceForUpdate(Object source, List<CommonGBChannel> channelList, List<CommonGBChannel> channelListForOld) {
|
||||
ChannelEvent channelEvent = new ChannelEvent(source);
|
||||
channelEvent.setMessageType(ChannelEventMessageType.UPDATE);
|
||||
channelEvent.setChannels(channelList);
|
||||
channelEvent.setOldChannels(channelListForOld);
|
||||
return channelEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.channel.ChannelEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||
@@ -75,7 +76,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
int result = commonGBChannelMapper.insert(commonGBChannel);
|
||||
try {
|
||||
// 发送通知
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannel, CatalogEvent.ADD);
|
||||
eventPublisher.channelEventPublish(commonGBChannel, ChannelEvent.ChannelEventMessageType.ADD);
|
||||
} catch (Exception e) {
|
||||
log.warn("[通道移除通知] 发送失败,{}", commonGBChannel.getGbDeviceId(), e);
|
||||
}
|
||||
@@ -97,7 +98,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
commonGBChannelMapper.delete(gbId);
|
||||
try {
|
||||
// 发送通知
|
||||
eventPublisher.catalogEventPublish(null, channel, CatalogEvent.DEL);
|
||||
eventPublisher.channelEventPublish(channel, ChannelEvent.ChannelEventMessageType.DELETE);
|
||||
} catch (Exception e) {
|
||||
log.warn("[通道移除通知] 发送失败,{}", channel.getGbDeviceId(), e);
|
||||
}
|
||||
@@ -139,15 +140,31 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
if (channels.size() > 1) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "国标编号重复,请修改编号后保存");
|
||||
}
|
||||
CommonGBChannel oldChannel = commonGBChannelMapper.queryById(commonGBChannel.getGbId());
|
||||
commonGBChannel.setUpdateTime(DateUtil.getNow());
|
||||
int result = commonGBChannelMapper.update(commonGBChannel);
|
||||
if (result > 0) {
|
||||
try {
|
||||
// 发送通知
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannel, CatalogEvent.UPDATE);
|
||||
eventPublisher.channelEventPublishForUpdate(commonGBChannel, oldChannel);
|
||||
} catch (Exception e) {
|
||||
log.warn("[更新通道通知] 发送失败,{}", commonGBChannel.getGbDeviceId(), e);
|
||||
}
|
||||
MobilePosition mobilePosition = new MobilePosition();
|
||||
mobilePosition.setLongitude(commonGBChannel.getGbLongitude());
|
||||
mobilePosition.setLatitude(commonGBChannel.getGbLatitude());
|
||||
mobilePosition.setCreateTime(DateUtil.getNow());
|
||||
mobilePosition.setDeviceId(commonGBChannel.getGbDeviceId());
|
||||
mobilePosition.setTime(DateUtil.getNow());
|
||||
mobilePosition.setAltitude(0.0);
|
||||
mobilePosition.setDirection(0.0);
|
||||
mobilePosition.setSpeed(0.0);
|
||||
mobilePosition.setChannelId(commonGBChannel.getGbId());
|
||||
try {
|
||||
eventPublisher.mobilePositionEventPublish(mobilePosition);
|
||||
}catch (Exception e) {
|
||||
log.error("[向上级转发移动位置失败] ", e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -162,7 +179,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
if (result > 0) {
|
||||
try {
|
||||
// 发送通知
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannel, CatalogEvent.OFF);
|
||||
eventPublisher.channelEventPublish(commonGBChannel, ChannelEvent.ChannelEventMessageType.OFFLINE);
|
||||
} catch (Exception e) {
|
||||
log.warn("[通道离线通知] 发送失败,{}", commonGBChannel.getGbDeviceId(), e);
|
||||
}
|
||||
@@ -194,7 +211,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
if (result > 0) {
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannelList, CatalogEvent.OFF);
|
||||
eventPublisher.channelEventPublish(commonGBChannelList, ChannelEvent.ChannelEventMessageType.OFFLINE);
|
||||
} catch (Exception e) {
|
||||
log.warn("[多个通道离线] 发送失败,数量:{}", commonGBChannelList.size(), e);
|
||||
}
|
||||
@@ -212,7 +229,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
if (result > 0) {
|
||||
try {
|
||||
// 发送通知
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannel, CatalogEvent.ON);
|
||||
eventPublisher.channelEventPublish(commonGBChannel, ChannelEvent.ChannelEventMessageType.ONLINE);
|
||||
} catch (Exception e) {
|
||||
log.warn("[通道上线通知] 发送失败,{}", commonGBChannel.getGbDeviceId(), e);
|
||||
}
|
||||
@@ -243,7 +260,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
}
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannelList, CatalogEvent.ON);
|
||||
eventPublisher.channelEventPublish(commonGBChannelList, ChannelEvent.ChannelEventMessageType.ONLINE);
|
||||
} catch (Exception e) {
|
||||
log.warn("[多个通道上线] 发送失败,数量:{}", commonGBChannelList.size(), e);
|
||||
}
|
||||
@@ -274,7 +291,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
}
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannels, CatalogEvent.ADD);
|
||||
eventPublisher.channelEventPublish(commonGBChannels, ChannelEvent.ChannelEventMessageType.ADD);
|
||||
} catch (Exception e) {
|
||||
log.warn("[多个通道新增] 发送失败,数量:{}", commonGBChannels.size(), e);
|
||||
}
|
||||
@@ -306,6 +323,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
try {
|
||||
// 发送通知
|
||||
eventPublisher.catalogEventPublish(null, commonGBChannels, CatalogEvent.UPDATE);
|
||||
// eventPublisher.channelEventPublishForUpdate(commonGBChannels, ChannelEvent.ChannelEventMessageType.ADD);
|
||||
} catch (Exception e) {
|
||||
log.warn("[更新多个通道] 发送失败,{}个", commonGBChannels.size(), e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user