设置默认直播通道并返回给808服务

master
chents 3 years ago
parent 04d3700961
commit 9b44dd353e
  1. 58
      src/main/java/org/springblade/common/enums/CarChannelEnum.java
  2. 18
      src/main/java/org/springblade/modules/business/controller/CarAdminController.java
  3. 35
      src/main/java/org/springblade/modules/business/controller/CommonApiController.java
  4. 2
      src/main/java/org/springblade/modules/business/entity/CarLiveChannel.java

@ -0,0 +1,58 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 系统字典枚举类
*
* @author Chill
*/
@Getter
@AllArgsConstructor
public enum CarChannelEnum {
DEFAULT(1, "默认"),
NO_UNREGISTER(2, "不默认"),
;
final Integer name;
final String value;
public static Integer getName(String val) {
for (ApmRecordStatusEnum value : ApmRecordStatusEnum.values()) {
if (value.getValue().equals(val)) {
return value.getName();
}
}
return -1;
}
public static String getValue(Integer name) {
for (ApmRecordStatusEnum value : ApmRecordStatusEnum.values()) {
if (value.getName().equals(name)) {
return value.getValue();
}
}
return "";
}
}

@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.enums.CarChannelEnum;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@ -76,17 +77,24 @@ public class CarAdminController extends BladeController {
// 遍历直播通道列表,设置外键为新增车辆信息的id,然后新增直播通道
List<CarLiveChannelVo> carLiveChannelVoList = carAdminVo.getCarLiveChannelVoList();
if (CollectionUtils.isNotEmpty(carLiveChannelVoList)) {
boolean hasDefault = false; // 是否已经存在默认通道
for (CarLiveChannelVo carLiveChannelVo : carLiveChannelVoList) {
carLiveChannelVo.setCarId(carId);
CarLiveChannel carLiveChannel = new CarLiveChannel();
BeanUtils.copyProperties(carLiveChannelVo, carLiveChannel);
if (carLiveChannelVo.getStatus() == 1) {
if (hasDefault) {
carLiveChannelVo.setStatus(2); // 如果已经存在默认通道,则将当前通道设置为非默认通道
} else {
hasDefault = true;
}
}
carLiveChannelService.save(carLiveChannel);
}
}
} else {
// 1. 修改车辆信息
carService.updateById(carAdmin);
// 2. 根据车辆id删除原有通道
QueryWrapper<CarLiveChannel> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("car_id",carAdmin.getId());
@ -95,10 +103,18 @@ public class CarAdminController extends BladeController {
Long carId = carAdmin.getId();
List<CarLiveChannelVo> carLiveChannelVoList = carAdminVo.getCarLiveChannelVoList();
if (CollectionUtils.isNotEmpty(carLiveChannelVoList)) {
boolean hasDefault = false; // 是否已经存在默认通道
for (CarLiveChannelVo carLiveChannelVo : carLiveChannelVoList) {
carLiveChannelVo.setCarId(carId);
CarLiveChannel carLiveChannel = new CarLiveChannel();
BeanUtils.copyProperties(carLiveChannelVo, carLiveChannel);
if (carLiveChannelVo.getStatus().equals(CarChannelEnum.DEFAULT.getName())) {
if (hasDefault) {
carLiveChannelVo.setStatus(CarChannelEnum.NO_UNREGISTER.getName()); // 如果已经存在默认通道,则将当前通道设置为非默认通道
} else {
hasDefault = true;
}
}
carLiveChannelService.save(carLiveChannel);
}
}

@ -2,7 +2,6 @@ package org.springblade.modules.business.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.beetl.core.util.ArrayMap;
@ -11,6 +10,7 @@ import org.springblade.common.cache.business.CarInfoCache;
import org.springblade.common.cache.business.SiteListCache;
import org.springblade.common.constant.BusinessConstant;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.enums.CarChannelEnum;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tenant.annotation.TenantDS;
@ -18,13 +18,14 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.business.entity.BusLine;
import org.springblade.modules.business.entity.CarAdmin;
import org.springblade.modules.business.entity.CarLiveChannel;
import org.springblade.modules.business.service.ICarAdminService;
import org.springblade.modules.business.service.ICarInfoService;
import org.springblade.modules.business.service.ICarLiveChannelService;
import org.springblade.modules.business.service.IStationHintService;
import org.springblade.modules.business.service.impl.PublishService;
import org.springblade.modules.business.vo.CarInfoVO;
import org.springblade.modules.business.vo.SiteInfoVO;
import org.springblade.modules.business.vo.imgVo;
import org.springblade.modules.job.CarInfoTask;
import org.springblade.upload.service.IProBusLineImgService;
import org.springframework.data.redis.core.RedisTemplate;
@ -59,14 +60,10 @@ public class CommonApiController extends BladeController {
private final PublishService publishService;
private final CarInfoTask carInfoTask;
private final IStationHintService stationHintService;
private final IProBusLineImgService proBusLineImgService;
private final ICarAdminService carAdminService;
private final ICarLiveChannelService carLiveChannelService;
/**
* 设置车牌号
*
@ -83,6 +80,28 @@ public class CommonApiController extends BladeController {
return R.status(true);
}
/**
* 获取车辆下的默认直播通道
* @return
*/
@GetMapping("get-car-channelNo")
public R getCarChannelNo(@RequestParam String clientId) {
CarAdmin carAdmin = carAdminService
.getOne(Wrappers.<CarAdmin>lambdaQuery().eq(CarAdmin::getReceiverId, clientId)
.select(CarAdmin::getId,CarAdmin::getName));
if (Func.isEmpty(carAdmin)){
return R.fail("车辆信息不存在");
}
CarLiveChannel carChannel = carLiveChannelService.getOne(Wrappers.<CarLiveChannel>lambdaQuery()
.eq(CarLiveChannel::getCarId, carAdmin.getId())
.eq(CarLiveChannel::getStatus, CarChannelEnum.DEFAULT.getName())
.select(CarLiveChannel::getCode));
HashMap<String, Object> channelMap = new HashMap<>();
channelMap.put("carNo",carAdmin.getName());
channelMap.put("channelNo",carChannel.getCode());
return R.data(channelMap);
}
/**
* 获取车牌号
*

@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* 文章表
* 直播通道
*
* @author Chill
*/

Loading…
Cancel
Save