fix(优化):订单显示手机号功能,视频流生成下发任务时一起下发
This commit is contained in:
+5
-1
@@ -17,6 +17,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -40,7 +41,10 @@ import java.util.stream.Collectors;
|
|||||||
@Tag(name = "设备管理")
|
@Tag(name = "设备管理")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AgeDeviceController {
|
public class AgeDeviceController {
|
||||||
private final IAgeDeviceService ageDeviceService;
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAgeDeviceService ageDeviceService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
|
|||||||
+11
-4
@@ -9,10 +9,10 @@ import com.central.device.message.ControlEnum;
|
|||||||
import com.central.device.message.ControlMessageConstant;
|
import com.central.device.message.ControlMessageConstant;
|
||||||
import com.central.device.model.LineFile;
|
import com.central.device.model.LineFile;
|
||||||
import com.central.device.service.ILineFileService;
|
import com.central.device.service.ILineFileService;
|
||||||
|
import com.central.device.service.LiveStreamService;
|
||||||
import com.central.device.util.IotRequestResult;
|
import com.central.device.util.IotRequestResult;
|
||||||
import com.central.device.util.MapUtil;
|
import com.central.device.util.MapUtil;
|
||||||
import com.central.device.util.RequestUtils;
|
import com.central.device.util.RequestUtils;
|
||||||
import com.central.device.util.http.HeaderUtils;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@@ -41,7 +41,7 @@ public class ApiDeviceController {
|
|||||||
private String baseUrl;// = "http://119.45.169.13:8848/";
|
private String baseUrl;// = "http://119.45.169.13:8848/";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HeaderUtils headerUtils;
|
private LiveStreamService liveStreamService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RequestUtils requestUtils;
|
private RequestUtils requestUtils;
|
||||||
@@ -92,7 +92,7 @@ public class ApiDeviceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. 构建控制消息
|
// 3. 构建控制消息
|
||||||
JsonObject controlMessage = buildControlMessage(control, orderNo);
|
JsonObject controlMessage = buildControlMessage(control, orderNo, deviceId);
|
||||||
if (controlMessage == null) {
|
if (controlMessage == null) {
|
||||||
return Result.succeed("暂未开放控制权限");
|
return Result.succeed("暂未开放控制权限");
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ public class ApiDeviceController {
|
|||||||
return !StringUtils.isEmpty(orderStatus) && orderStatus.equals("1");
|
return !StringUtils.isEmpty(orderStatus) && orderStatus.equals("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonObject buildControlMessage(String control, String orderNo) {
|
private JsonObject buildControlMessage(String control, String orderNo, String deviceId) {
|
||||||
if (!ControlEnum.contains(ControlEnum.valueOf(control.toUpperCase()))) {
|
if (!ControlEnum.contains(ControlEnum.valueOf(control.toUpperCase()))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -138,6 +138,13 @@ public class ApiDeviceController {
|
|||||||
LineFile lineFile = lineFileService.findLineFileByWaylineId(waylineId);
|
LineFile lineFile = lineFileService.findLineFileByWaylineId(waylineId);
|
||||||
Assert.notNull(lineFile,"航线文件签名不正确");
|
Assert.notNull(lineFile,"航线文件签名不正确");
|
||||||
data.addProperty("file_md5", lineFile.getSign());
|
data.addProperty("file_md5", lineFile.getSign());
|
||||||
|
// 设置设备视频流地址
|
||||||
|
try {
|
||||||
|
data.addProperty("stream_urls", liveStreamService.generateStreamUrls(deviceId).toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("生成设备推流/拉流地址异常: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||||
|
data.addProperty("stream_urls", "{}"); // 或者空字符串 ""
|
||||||
|
}
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.central.device.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.central.device.service.LiveStreamService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/live")
|
||||||
|
public class LiveStreamController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LiveStreamService liveStreamService;
|
||||||
|
|
||||||
|
@GetMapping("/stream-urls")
|
||||||
|
public JSONObject getStreamUrls(@RequestParam String deviceId) {
|
||||||
|
return liveStreamService.generateStreamUrls(deviceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-8
@@ -1,11 +1,13 @@
|
|||||||
package com.central.order.service;
|
package com.central.device.service;
|
||||||
|
|
||||||
import com.central.order.util.TencentLiveUtil;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.central.device.util.TencentLiveUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LiveStreamService {
|
public class LiveStreamService {
|
||||||
@@ -21,21 +23,36 @@ public class LiveStreamService {
|
|||||||
@Value("${tencent.live.expire-seconds:3600}")
|
@Value("${tencent.live.expire-seconds:3600}")
|
||||||
private long expireSeconds;
|
private long expireSeconds;
|
||||||
|
|
||||||
|
private static final String STREAM_URL_KEY_PREFIX = "device:stream_urls:";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成设备推流和拉流地址
|
* 生成设备推流和拉流地址,并缓存到Redis
|
||||||
*/
|
*/
|
||||||
public Map<String, String> generateStreamUrls(String deviceId) {
|
public JSONObject generateStreamUrls(String deviceId) {
|
||||||
|
String cacheKey = STREAM_URL_KEY_PREFIX + deviceId;
|
||||||
|
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||||
|
if (cacheValue != null) {
|
||||||
|
return JSONObject.parseObject(cacheValue);
|
||||||
|
}
|
||||||
|
|
||||||
long expire = System.currentTimeMillis() / 1000 + expireSeconds;
|
long expire = System.currentTimeMillis() / 1000 + expireSeconds;
|
||||||
String pushUrl = TencentLiveUtil.generatePushUrl(pushDomain, appName, deviceId, key, expire);
|
String pushUrl = TencentLiveUtil.generatePushUrl(pushDomain, appName, deviceId, key, expire);
|
||||||
String playRtmpUrl = TencentLiveUtil.generatePlayUrl(playDomain, appName, deviceId, "rtmp");
|
String playRtmpUrl = TencentLiveUtil.generatePlayUrl(playDomain, appName, deviceId, "rtmp");
|
||||||
String playFlvUrl = TencentLiveUtil.generatePlayUrl(playDomain, appName, deviceId, "flv");
|
String playFlvUrl = TencentLiveUtil.generatePlayUrl(playDomain, appName, deviceId, "flv");
|
||||||
String playM3u8Url = TencentLiveUtil.generatePlayUrl(playDomain, appName, deviceId, "m3u8");
|
String playM3u8Url = TencentLiveUtil.generatePlayUrl(playDomain, appName, deviceId, "m3u8");
|
||||||
|
|
||||||
Map<String, String> result = new HashMap<>();
|
JSONObject result = new JSONObject();
|
||||||
result.put("pushUrl", pushUrl);
|
result.put("pushUrl", pushUrl);
|
||||||
result.put("playRtmpUrl", playRtmpUrl);
|
result.put("playRtmpUrl", playRtmpUrl);
|
||||||
result.put("playFlvUrl", playFlvUrl);
|
result.put("playFlvUrl", playFlvUrl);
|
||||||
result.put("playM3u8Url", playM3u8Url);
|
result.put("playM3u8Url", playM3u8Url);
|
||||||
|
|
||||||
|
// 缓存到redis,设置过期时间(如1小时)
|
||||||
|
redisTemplate.opsForValue().set(cacheKey, result.toJSONString(), 1, TimeUnit.HOURS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.central.order.util;
|
package com.central.device.util;
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
|
||||||
@@ -40,3 +40,10 @@ jetlinks:
|
|||||||
# jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/logger-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
# jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/logger-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||||
# username: ${zlt.datasource.username}
|
# username: ${zlt.datasource.username}
|
||||||
# password: ${zlt.datasource.password}
|
# password: ${zlt.datasource.password}
|
||||||
|
tencent:
|
||||||
|
live:
|
||||||
|
push-domain: 208280.push.tlivecloud.com
|
||||||
|
play-domain: goflytec.com
|
||||||
|
expire-seconds: 3600 #过期时间为1小时
|
||||||
|
app-name: live
|
||||||
|
key: 06b20e5b7d637c1128fa1b48ea91a13e
|
||||||
|
|||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package com.central.order.controller;
|
|
||||||
|
|
||||||
import com.central.order.service.LiveStreamService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/live")
|
|
||||||
public class LiveStreamController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LiveStreamService liveStreamService;
|
|
||||||
|
|
||||||
@GetMapping("/stream-urls")
|
|
||||||
public Map<String, String> getStreamUrls(@RequestParam String deviceId) {
|
|
||||||
return liveStreamService.generateStreamUrls(deviceId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
@@ -559,6 +559,7 @@ public class OrderController {
|
|||||||
detailMap.put("orderAmount", appendPriceStr(order.getOrderAmount()));
|
detailMap.put("orderAmount", appendPriceStr(order.getOrderAmount()));
|
||||||
detailMap.put("createTime", sdf.format(order.getCreateTime()));
|
detailMap.put("createTime", sdf.format(order.getCreateTime()));
|
||||||
detailMap.put("deviceSn", order.getDeviceSn());
|
detailMap.put("deviceSn", order.getDeviceSn());
|
||||||
|
detailMap.put("mobile", order.getMobile());
|
||||||
|
|
||||||
// 景区信息
|
// 景区信息
|
||||||
Map<String, Object> tourismMap = new HashMap<>();
|
Map<String, Object> tourismMap = new HashMap<>();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class Order extends SuperEntity {
|
|||||||
|
|
||||||
private transient String createdTime;
|
private transient String createdTime;
|
||||||
private transient String fileMd5;
|
private transient String fileMd5;
|
||||||
|
private transient String mobile;
|
||||||
|
|
||||||
private String codeId;
|
private String codeId;
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
|||||||
+5
-2
@@ -7,13 +7,13 @@ import com.central.common.model.PageResult;
|
|||||||
import com.central.common.service.impl.SuperServiceImpl;
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
import com.central.order.event.OrderStatusChangeEvent;
|
import com.central.order.event.OrderStatusChangeEvent;
|
||||||
|
import com.central.order.feign.UserCenterService;
|
||||||
import com.central.order.mapper.OrderFileMapper;
|
import com.central.order.mapper.OrderFileMapper;
|
||||||
import com.central.order.mapper.OrderMapper;
|
import com.central.order.mapper.OrderMapper;
|
||||||
import com.central.order.mapper.TourismMapper;
|
import com.central.order.mapper.TourismMapper;
|
||||||
import com.central.order.model.Order;
|
import com.central.order.model.Order;
|
||||||
import com.central.order.model.OrderFile;
|
import com.central.order.model.OrderFile;
|
||||||
import com.central.order.model.OrderRanking;
|
import com.central.order.model.OrderRanking;
|
||||||
import com.central.order.service.IMessageService;
|
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
import com.central.order.util.DateUtils;
|
import com.central.order.util.DateUtils;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||||
@@ -67,7 +67,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|||||||
private ApplicationEventPublisher eventPublisher;
|
private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMessageService messageService;
|
private UserCenterService userCenterService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
@@ -78,6 +78,9 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|||||||
public PageResult<Order> findList(Map<String, Object> params){
|
public PageResult<Order> findList(Map<String, Object> params){
|
||||||
Page<Order> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
Page<Order> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
List<Order> list = baseMapper.findList(page, params);
|
List<Order> list = baseMapper.findList(page, params);
|
||||||
|
for (Order order : list){
|
||||||
|
order.setMobile(userCenterService.findUserById(order.getUserId()).getMobile());
|
||||||
|
}
|
||||||
return PageResult.<Order>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
return PageResult.<Order>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,12 +60,8 @@ tencent:
|
|||||||
async-pool-size: 5
|
async-pool-size: 5
|
||||||
api:
|
api:
|
||||||
profit-sharing-url: https://api.mch.weixin.qq.com/v3/profitsharing/orders
|
profit-sharing-url: https://api.mch.weixin.qq.com/v3/profitsharing/orders
|
||||||
live:
|
|
||||||
push-domain: 208280.push.tlivecloud.com
|
|
||||||
play-domain: goflytec.com
|
|
||||||
app-name: live
|
|
||||||
key: 06b20e5b7d637c1128fa1b48ea91a13e
|
|
||||||
expire-seconds: 3600000
|
|
||||||
file:
|
file:
|
||||||
oss-url: goflyapp.oss-cn-beijing.aliyuncs.com
|
oss-url: goflyapp.oss-cn-beijing.aliyuncs.com
|
||||||
cdn-url: cdn.goflytec.com
|
cdn-url: cdn.goflytec.com
|
||||||
|
|||||||
+3
-3
@@ -30,9 +30,9 @@ const DetailModal: React.FC<DetailModalProps> = ({ visible, onClose, data, loadi
|
|||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="订单金额">¥{data.orderAmount}</Descriptions.Item>
|
<Descriptions.Item label="订单金额">¥{data.orderAmount}</Descriptions.Item>
|
||||||
<Descriptions.Item label="设备编号">{data.deviceSn}</Descriptions.Item>
|
<Descriptions.Item label="设备编号">{data.deviceSn}</Descriptions.Item>
|
||||||
<Descriptions.Item label="创建时间" span={2}>
|
<Descriptions.Item label="用户手机号">{data.mobile}</Descriptions.Item>
|
||||||
{data.createTime}
|
<Descriptions.Item label="创建时间">{data.createTime}</Descriptions.Item>
|
||||||
</Descriptions.Item>
|
|
||||||
|
|
||||||
<Descriptions.Item label="景区名称" span={2}>
|
<Descriptions.Item label="景区名称" span={2}>
|
||||||
{data.tourism.tourismName}
|
{data.tourism.tourismName}
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ const TableList: React.FC = () => {
|
|||||||
copyable: true,
|
copyable: true,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '用户手机号',
|
||||||
|
dataIndex: 'mobile',
|
||||||
|
copyable: true,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '二维码ID',
|
title: '二维码ID',
|
||||||
dataIndex: 'codeId',
|
dataIndex: 'codeId',
|
||||||
|
|||||||
Reference in New Issue
Block a user