|
@@ -34,11 +34,14 @@ public class TencentPushController {
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
public Map<String, Object> tencentpush(@RequestBody Map<String, String> json) throws Exception {
|
|
public Map<String, Object> tencentpush(@RequestBody Map<String, String> json) throws Exception {
|
|
|
|
|
|
|
|
|
|
+ log.info("推送信息:" + JSON.toJSON(json));
|
|
|
|
|
+
|
|
|
String channelId = json.get("channel_id");
|
|
String channelId = json.get("channel_id");
|
|
|
|
|
|
|
|
- Map<String, String> map = split(json.get("stream_param"));
|
|
|
|
|
if (channelId.contains("share")) {
|
|
if (channelId.contains("share")) {
|
|
|
|
|
+ log.info("pc端的推送信息:" + JSON.toJSON(json));
|
|
|
// 转成json形式
|
|
// 转成json形式
|
|
|
|
|
+ Map<String, String> map = split(json.get("stream_param"));
|
|
|
String fileId = (String) json.get("file_id");
|
|
String fileId = (String) json.get("file_id");
|
|
|
PushDataEntity pushData = new PushDataEntity();
|
|
PushDataEntity pushData = new PushDataEntity();
|
|
|
pushData.setFileId(fileId);
|
|
pushData.setFileId(fileId);
|
|
@@ -47,7 +50,6 @@ public class TencentPushController {
|
|
|
pushData.setData(JSON.toJSONString(json));
|
|
pushData.setData(JSON.toJSONString(json));
|
|
|
pushData.setPath(json.get("video_url"));
|
|
pushData.setPath(json.get("video_url"));
|
|
|
pushDataMapper.insert(pushData);
|
|
pushDataMapper.insert(pushData);
|
|
|
- log.info("pc端的推送信息:" + JSON.toJSON(json));
|
|
|
|
|
// 文件fileId
|
|
// 文件fileId
|
|
|
String roomId = map.get("groupid");
|
|
String roomId = map.get("groupid");
|
|
|
QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
|
|
QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
|
|
@@ -68,6 +70,8 @@ public class TencentPushController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (channelId.contains("aux")) {
|
|
if (channelId.contains("aux")) {
|
|
|
|
|
+ log.info("app的视频推送:" + JSON.toJSON(json));
|
|
|
|
|
+ Map<String, String> map = split(json.get("stream_param"));
|
|
|
// 转成json形式
|
|
// 转成json形式
|
|
|
String fileId = (String) json.get("file_id");
|
|
String fileId = (String) json.get("file_id");
|
|
|
PushDataEntity pushData = new PushDataEntity();
|
|
PushDataEntity pushData = new PushDataEntity();
|
|
@@ -77,7 +81,7 @@ public class TencentPushController {
|
|
|
pushData.setData(JSON.toJSONString(json));
|
|
pushData.setData(JSON.toJSONString(json));
|
|
|
pushData.setPath(json.get("video_url"));
|
|
pushData.setPath(json.get("video_url"));
|
|
|
pushDataMapper.insert(pushData);
|
|
pushDataMapper.insert(pushData);
|
|
|
- log.info("app的视频推送:" + JSON.toJSON(json));
|
|
|
|
|
|
|
+
|
|
|
// 文件fileId
|
|
// 文件fileId
|
|
|
String roomId = map.get("groupid");
|
|
String roomId = map.get("groupid");
|
|
|
QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
|
|
QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
|
|
@@ -103,126 +107,67 @@ public class TencentPushController {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// @AnonymousPostMapping("/apppush")
|
|
|
|
|
|
|
+ @AnonymousPostMapping("/nt")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public Map<String, Object> apppush(@RequestBody JSONObject json) throws Exception {
|
|
|
|
|
|
|
+ public Map<String, Object> nt(@RequestBody JSONObject json) throws Exception {
|
|
|
Object data = JSON.toJSON(json);
|
|
Object data = JSON.toJSON(json);
|
|
|
- log.info("app的视频推送start######################################################################################");
|
|
|
|
|
- log.info("app的视频推送:" + data);
|
|
|
|
|
- log.info("app的视频推送end########################################################################################");
|
|
|
|
|
- // pushData.set
|
|
|
|
|
- String eventType = json.getString("EventType");
|
|
|
|
|
- if (eventType != null && eventType.equalsIgnoreCase("ProcedureStateChanged")) {
|
|
|
|
|
- JSONObject procedureState = json.getJSONObject("ProcedureStateChangeEvent");
|
|
|
|
|
- if (procedureState != null) {
|
|
|
|
|
- JSONArray mediaProcess = procedureState.getJSONArray("MediaProcessResultSet");
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < mediaProcess.size(); i++) {
|
|
|
|
|
- JSONObject map = mediaProcess.getJSONObject(i);
|
|
|
|
|
- if (map.get("Type") != null && map.getString("Type").equalsIgnoreCase("Transcode")) {
|
|
|
|
|
- JSONObject videoUrl = map.getJSONObject("TranscodeTask").getJSONObject("Output");
|
|
|
|
|
- // 通过id查询房间号码
|
|
|
|
|
- String fileId = procedureState.getString("FileId");
|
|
|
|
|
- QueryWrapper<PushDataEntity> query = new QueryWrapper<>();
|
|
|
|
|
- query.eq("file_id", fileId);
|
|
|
|
|
- query.eq("push_type", "app");
|
|
|
|
|
- query.eq("type_name", "live");
|
|
|
|
|
- List<PushDataEntity> file = pushDataMapper.selectList(query);
|
|
|
|
|
- if (file != null && file.size() > 0) {
|
|
|
|
|
- String pushData = file.get(0).getData();
|
|
|
|
|
- JSONObject jsonObj = JSONObject.parseObject(pushData);
|
|
|
|
|
- String streamParam = jsonObj.getString("stream_param");
|
|
|
|
|
- Map<String, String> param = split(streamParam);
|
|
|
|
|
- String roomId = param.get("roomId");
|
|
|
|
|
- OrderRoomIdEntity orderRoomId = new OrderRoomIdEntity();
|
|
|
|
|
- orderRoomId.setAppFileId(fileId);
|
|
|
|
|
-
|
|
|
|
|
- String filePath = orderRoomId.getBusinessNo() + "/";
|
|
|
|
|
- String fileName = filePath + "/APP" + fileId + ".mp4";
|
|
|
|
|
- DownloadUtils.downloadFile(videoUrl.get("Url").toString(), fileName);
|
|
|
|
|
- orderRoomId.setAppVideoUrl(fileName);
|
|
|
|
|
- //
|
|
|
|
|
- UpdateWrapper<OrderRoomIdEntity> updateQw = new UpdateWrapper<>();
|
|
|
|
|
- updateQw.eq("roomId", roomId);
|
|
|
|
|
- orderRoomIdMapper.update(orderRoomId, updateQw);
|
|
|
|
|
- PushDataEntity pushDataEntity = new PushDataEntity();
|
|
|
|
|
- pushDataEntity.setFileId(fileId);
|
|
|
|
|
- pushDataEntity.setPushType("app");
|
|
|
|
|
- pushDataEntity.setData(JSON.toJSONString(json));
|
|
|
|
|
- pushDataEntity.setPath(videoUrl.get("Url").toString());
|
|
|
|
|
- pushDataEntity.setTypeName("ProcedureStateChangeEvent");
|
|
|
|
|
- pushDataMapper.insert(pushDataEntity);
|
|
|
|
|
- } else {
|
|
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
|
|
- result.put("success", false);
|
|
|
|
|
- result.put("code", 100);
|
|
|
|
|
- return result;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if (eventType != null && eventType.equalsIgnoreCase("NewFileUpload")) {
|
|
|
|
|
- // FileUploadEvent
|
|
|
|
|
- JSONObject jsonObject = json.getJSONObject("FileUploadEvent");
|
|
|
|
|
- String fileId = jsonObject.getString("FileId");
|
|
|
|
|
- JSONObject mediaBasicInfo = jsonObject.getJSONObject("MediaBasicInfo");
|
|
|
|
|
- String path = mediaBasicInfo.getString("MediaUrl");
|
|
|
|
|
- // 这里判断
|
|
|
|
|
- String name = mediaBasicInfo.getString("Name");
|
|
|
|
|
- if (name.contains("aux")) {
|
|
|
|
|
- JSONObject sourceInfo = mediaBasicInfo.getJSONObject("SourceInfo");
|
|
|
|
|
- String sourceContext = sourceInfo.getString("SourceContext");
|
|
|
|
|
- Map<String, String> map = split(sourceContext);
|
|
|
|
|
- String roomId = map.get("groupid");
|
|
|
|
|
- QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
|
|
|
|
|
- orderRoomQuery.eq("roomId", roomId);
|
|
|
|
|
- orderRoomQuery.orderByDesc("create_time");
|
|
|
|
|
- List<OrderRoomIdEntity> orderRoomId = orderRoomIdMapper.selectList(orderRoomQuery);
|
|
|
|
|
|
|
+ log.info("############################推送信息[start]##############################################");
|
|
|
|
|
+ log.info("推送信息:" + JSON.toJSON(data));
|
|
|
|
|
+ log.info("############################推送信息[end]##############################################");
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObj = json.getJSONObject("EventInfo");
|
|
|
|
|
+ String roomId = jsonObj.getString("RoomId");
|
|
|
|
|
+ jsonObj = jsonObj.getJSONObject("Payload");
|
|
|
|
|
+
|
|
|
|
|
+ jsonObj = jsonObj.getJSONObject("TencentVod");
|
|
|
|
|
+ if (jsonObj == null) {
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
|
+ result.put("success", false);
|
|
|
|
|
+ result.put("msg", "视频不完整");
|
|
|
|
|
+ result.put("code", 201);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ String mediaId = jsonObj.getString("MediaId");
|
|
|
|
|
|
|
|
- if (orderRoomId != null && orderRoomId.size() > 0) {
|
|
|
|
|
- OrderRoomIdEntity orderRoomIdEntity = orderRoomId.get(0);
|
|
|
|
|
|
|
+ String fileId = jsonObj.getString("FileId");
|
|
|
|
|
+ String videoUrl = jsonObj.getString("VideoUrl");
|
|
|
|
|
|
|
|
- String filePath = orderRoomIdEntity.getBusinessNo() + "/";
|
|
|
|
|
- String fileName = filePath + "/APP" + fileId + ".mp4";
|
|
|
|
|
- DownloadUtils.downloadFile(path, fileName);
|
|
|
|
|
- OrderRoomIdEntity update = new OrderRoomIdEntity();
|
|
|
|
|
- update.setPcFileId(fileId);
|
|
|
|
|
- update.setAppVideoUrl(fileName);
|
|
|
|
|
- update.setId(orderRoomIdEntity.getId());
|
|
|
|
|
- orderRoomIdMapper.updateById(update);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String userId = jsonObj.getString("UserId");
|
|
|
|
|
+ // app的推送
|
|
|
|
|
+ if (mediaId.contains("aux")) {
|
|
|
|
|
+ QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
|
|
|
|
|
+ orderRoomQuery.eq("roomId", roomId);
|
|
|
|
|
+ orderRoomQuery.orderByDesc("create_time");
|
|
|
|
|
+ List<OrderRoomIdEntity> orderRoomId = orderRoomIdMapper.selectList(orderRoomQuery);
|
|
|
|
|
+ // 这里通过订单查询相关信息
|
|
|
|
|
+ if (orderRoomId != null && orderRoomId.size() > 0) {
|
|
|
|
|
+ OrderRoomIdEntity orderRoomIdEntity = orderRoomId.get(0);
|
|
|
|
|
+ String filePath = orderRoomIdEntity.getBusinessNo();
|
|
|
|
|
+ String fileName = filePath + "/APP" + fileId + ".mp4";
|
|
|
|
|
+ DownloadUtils.downloadFile(videoUrl, fileName);
|
|
|
|
|
+ OrderRoomIdEntity update = new OrderRoomIdEntity();
|
|
|
|
|
+ update.setAppFileId(fileId);
|
|
|
|
|
+ update.setAppVideoUrl(fileName);
|
|
|
|
|
+ update.setId(orderRoomIdEntity.getId());
|
|
|
|
|
+ orderRoomIdMapper.updateById(update);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- PushDataEntity PushDataEntity = new PushDataEntity();
|
|
|
|
|
- PushDataEntity.setFileId(fileId);
|
|
|
|
|
- PushDataEntity.setTypeName(eventType);
|
|
|
|
|
- PushDataEntity.setPushType("app");
|
|
|
|
|
- PushDataEntity.setData(JSON.toJSONString(json));
|
|
|
|
|
- PushDataEntity.setPath(path);
|
|
|
|
|
- PushDataEntity.setTypeName(eventType);
|
|
|
|
|
- pushDataMapper.insert(PushDataEntity);
|
|
|
|
|
- // 保存推送过来的视频
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- // 处理"appname": "live",
|
|
|
|
|
- String live = json.getString("appname");
|
|
|
|
|
- if (live.equalsIgnoreCase("live")) {
|
|
|
|
|
- PushDataEntity pushDataEntity = new PushDataEntity();
|
|
|
|
|
- pushDataEntity.setFileId(json.getString("file_id"));
|
|
|
|
|
- pushDataEntity.setPushType("app");
|
|
|
|
|
- pushDataEntity.setData(JSON.toJSONString(json));
|
|
|
|
|
- pushDataEntity.setPath(json.getString("video_url"));
|
|
|
|
|
- pushDataEntity.setTypeName(json.getString("appname"));
|
|
|
|
|
- pushDataMapper.insert(pushDataEntity);
|
|
|
|
|
- } else {
|
|
|
|
|
- PushDataEntity pushDataEntity = new PushDataEntity();
|
|
|
|
|
- pushDataEntity.setFileId("");
|
|
|
|
|
- pushDataEntity.setPushType("app");
|
|
|
|
|
- pushDataEntity.setData(JSON.toJSONString(json));
|
|
|
|
|
- pushDataEntity.setPath("");
|
|
|
|
|
- pushDataMapper.insert(pushDataEntity);
|
|
|
|
|
|
|
+ } else if (userId.contains("share")) {
|
|
|
|
|
+ QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
|
|
|
|
|
+ orderRoomQuery.eq("roomId", roomId);
|
|
|
|
|
+ orderRoomQuery.orderByDesc("create_time");
|
|
|
|
|
+ List<OrderRoomIdEntity> orderRoomId = orderRoomIdMapper.selectList(orderRoomQuery);
|
|
|
|
|
+ // 这里通过订单查询相关信息
|
|
|
|
|
+ if (orderRoomId != null && orderRoomId.size() > 0) {
|
|
|
|
|
+ OrderRoomIdEntity orderRoomIdEntity = orderRoomId.get(0);
|
|
|
|
|
+ String filePath = orderRoomIdEntity.getBusinessNo();
|
|
|
|
|
+ String fileName = filePath + "/PC" + fileId + ".mp4";
|
|
|
|
|
+ DownloadUtils.downloadFile(videoUrl, fileName);
|
|
|
|
|
+ OrderRoomIdEntity update = new OrderRoomIdEntity();
|
|
|
|
|
+ update.setPcFileId(fileId);
|
|
|
|
|
+ update.setPcVideoUrl(fileName);
|
|
|
|
|
+ update.setId(orderRoomIdEntity.getId());
|
|
|
|
|
+ orderRoomIdMapper.updateById(update);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("success", true);
|
|
result.put("success", true);
|