Showing
6 changed files
with
98 additions
and
13 deletions
| @@ -18,7 +18,7 @@ public class OperationLog { | @@ -18,7 +18,7 @@ public class OperationLog { | ||
| 18 | @TableId (type = IdType.AUTO) | 18 | @TableId (type = IdType.AUTO) |
| 19 | private Long id; | 19 | private Long id; |
| 20 | /** 业务ID */ | 20 | /** 业务ID */ |
| 21 | - private String businesId; | 21 | + private String businessId; |
| 22 | /** 业务类型(如 cloudMonitor-云审片) */ | 22 | /** 业务类型(如 cloudMonitor-云审片) */ |
| 23 | private String businessType; | 23 | private String businessType; |
| 24 | /** 操作类型(音画屏蔽、画面屏蔽、恢复、延时、标记) */ | 24 | /** 操作类型(音画屏蔽、画面屏蔽、恢复、延时、标记) */ |
| @@ -38,6 +38,10 @@ public class OperationLog { | @@ -38,6 +38,10 @@ public class OperationLog { | ||
| 38 | private String reponseCode; | 38 | private String reponseCode; |
| 39 | /** 操作状态(0-成功 1-失败) */ | 39 | /** 操作状态(0-成功 1-失败) */ |
| 40 | private String status; | 40 | private String status; |
| 41 | + /** 审片间名称 */ | ||
| 42 | + private String roomName; | ||
| 43 | + /** 描述信息 */ | ||
| 44 | + private String message; | ||
| 41 | 45 | ||
| 42 | 46 | ||
| 43 | } | 47 | } |
| @@ -6,8 +6,9 @@ package com.wondertek.enums; | @@ -6,8 +6,9 @@ package com.wondertek.enums; | ||
| 6 | public enum RoomOperationEnum { | 6 | public enum RoomOperationEnum { |
| 7 | MARK_START("markStart", "标记开始"), | 7 | MARK_START("markStart", "标记开始"), |
| 8 | MARK_EDN("markEnd", "标记结束"), | 8 | MARK_EDN("markEnd", "标记结束"), |
| 9 | - BLOCK("block", "屏蔽"), | ||
| 10 | - RECOVER("recover", "恢复"); | 9 | + BLOCK("block", "音画屏蔽"), |
| 10 | + RECOVER("recover", "音画恢复"), | ||
| 11 | + DELAY("delay", "延时"); | ||
| 11 | 12 | ||
| 12 | 13 | ||
| 13 | private final String code; | 14 | private final String code; |
| @@ -12,4 +12,6 @@ import com.wondertek.util.PageBean; | @@ -12,4 +12,6 @@ import com.wondertek.util.PageBean; | ||
| 12 | */ | 12 | */ |
| 13 | public interface OperationLogService { | 13 | public interface OperationLogService { |
| 14 | PageBean pageList(OperationLogDto operationLogDto); | 14 | PageBean pageList(OperationLogDto operationLogDto); |
| 15 | + | ||
| 16 | + void save(OperationLog opLog); | ||
| 15 | } | 17 | } |
| @@ -35,4 +35,9 @@ public class OperationLogServiceImpl implements OperationLogService { | @@ -35,4 +35,9 @@ public class OperationLogServiceImpl implements OperationLogService { | ||
| 35 | return new PageBean(Integer.parseInt(String.valueOf(resultPage.getPages())),resultPage.getTotal(),resultPage.getRecords()); | 35 | return new PageBean(Integer.parseInt(String.valueOf(resultPage.getPages())),resultPage.getTotal(),resultPage.getRecords()); |
| 36 | 36 | ||
| 37 | } | 37 | } |
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public void save(OperationLog opLog) { | ||
| 41 | + operationLogMapper.insertOrUpdate(opLog); | ||
| 42 | + } | ||
| 38 | } | 43 | } |
| @@ -11,13 +11,16 @@ import com.wondertek.dto.DelayParam; | @@ -11,13 +11,16 @@ import com.wondertek.dto.DelayParam; | ||
| 11 | import com.wondertek.dto.MarkParam; | 11 | import com.wondertek.dto.MarkParam; |
| 12 | import com.wondertek.entity.LiveMonitorRoom; | 12 | import com.wondertek.entity.LiveMonitorRoom; |
| 13 | import com.wondertek.entity.MonitorMark; | 13 | import com.wondertek.entity.MonitorMark; |
| 14 | +import com.wondertek.entity.OperationLog; | ||
| 14 | import com.wondertek.entity.StreamTask; | 15 | import com.wondertek.entity.StreamTask; |
| 16 | +import com.wondertek.enums.GlobalCodeEnum; | ||
| 15 | import com.wondertek.enums.RoomOperationEnum; | 17 | import com.wondertek.enums.RoomOperationEnum; |
| 16 | import com.wondertek.exception.BusinessException; | 18 | import com.wondertek.exception.BusinessException; |
| 17 | import com.wondertek.exception.ServiceException; | 19 | import com.wondertek.exception.ServiceException; |
| 18 | import com.wondertek.mapper.LiveMonitorRoomMapper; | 20 | import com.wondertek.mapper.LiveMonitorRoomMapper; |
| 19 | import com.wondertek.mapper.MonitorMarkMapper; | 21 | import com.wondertek.mapper.MonitorMarkMapper; |
| 20 | import com.wondertek.mapper.StreamTaskMapper; | 22 | import com.wondertek.mapper.StreamTaskMapper; |
| 23 | +import com.wondertek.service.OperationLogService; | ||
| 21 | import com.wondertek.service.RoomOperationSerivice; | 24 | import com.wondertek.service.RoomOperationSerivice; |
| 22 | import com.wondertek.util.JSONUtils; | 25 | import com.wondertek.util.JSONUtils; |
| 23 | import com.wondertek.util.ResponseData; | 26 | import com.wondertek.util.ResponseData; |
| @@ -55,41 +58,68 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | @@ -55,41 +58,68 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | ||
| 55 | private String blockStatusUrl; | 58 | private String blockStatusUrl; |
| 56 | @Resource | 59 | @Resource |
| 57 | private MonitorMarkMapper monitorMarkMapper; | 60 | private MonitorMarkMapper monitorMarkMapper; |
| 61 | + @Resource | ||
| 62 | + private OperationLogService operationLogService; | ||
| 58 | 63 | ||
| 59 | @Override | 64 | @Override |
| 60 | public ResultBean setDelayTime(DelayParam delayParam) { | 65 | public ResultBean setDelayTime(DelayParam delayParam) { |
| 61 | LiveMonitorRoom liveMonitorRoom = liveMonitorRoomMapper.selectById(delayParam.getRoomId()); | 66 | LiveMonitorRoom liveMonitorRoom = liveMonitorRoomMapper.selectById(delayParam.getRoomId()); |
| 67 | + //日志 | ||
| 68 | + OperationLog opLog = new OperationLog(); | ||
| 69 | + opLog.setRoomName(liveMonitorRoom.getName()); | ||
| 70 | + opLog.setBusinessId(delayParam.getRoomId().toString()); | ||
| 71 | + opLog.setBusinessType("cloudMonitor"); | ||
| 72 | + opLog.setOperationType(RoomOperationEnum.DELAY.getCode()); | ||
| 73 | + opLog.setCreatedBy("admin"); | ||
| 74 | + opLog.setCreatedTime(LocalDateTime.now()); | ||
| 75 | + opLog.setRequestUrl(delayTimeUrl); | ||
| 76 | + | ||
| 62 | LambdaQueryWrapper<StreamTask> wrapper = new LambdaQueryWrapper<>(); | 77 | LambdaQueryWrapper<StreamTask> wrapper = new LambdaQueryWrapper<>(); |
| 63 | wrapper.eq(StreamTask::getRoomId,delayParam.getRoomId()); | 78 | wrapper.eq(StreamTask::getRoomId,delayParam.getRoomId()); |
| 64 | List<StreamTask> streamTasks = streamTaskMapper.selectList(wrapper); | 79 | List<StreamTask> streamTasks = streamTaskMapper.selectList(wrapper); |
| 65 | //1.依次取出延时1、延时2、播出任务,设置转码平台相应的延时时间 | 80 | //1.依次取出延时1、延时2、播出任务,设置转码平台相应的延时时间 |
| 66 | - streamTasks.forEach(streamTask -> { | 81 | + for (StreamTask streamTask : streamTasks){ |
| 67 | if (streamTask.getPlayType().equals("delay1")){ | 82 | if (streamTask.getPlayType().equals("delay1")){ |
| 68 | - delayTask(streamTask.getTaskId(),delayParam.getDelayFirst()); | 83 | + ResponseData responseData = delayTask(streamTask.getTaskId(), delayParam.getDelayFirst()); |
| 84 | + if (!responseData.isSuccess()){ | ||
| 85 | + opLog.setStatus("1"); | ||
| 86 | + opLog.setReponseResult(JSONUtils.obj2json(responseData)); | ||
| 87 | + return ResultBean.error(); | ||
| 88 | + } | ||
| 69 | //更新任务 | 89 | //更新任务 |
| 70 | streamTask.setDelayTime(delayParam.getDelayFirst()); | 90 | streamTask.setDelayTime(delayParam.getDelayFirst()); |
| 71 | streamTaskMapper.updateById(streamTask); | 91 | streamTaskMapper.updateById(streamTask); |
| 72 | } | 92 | } |
| 73 | if (streamTask.getPlayType().equals("delay2")){ | 93 | if (streamTask.getPlayType().equals("delay2")){ |
| 74 | - delayTask(streamTask.getTaskId(),delayParam.getDelaySecond()); | 94 | + ResponseData responseData = delayTask(streamTask.getTaskId(),delayParam.getDelaySecond()); |
| 95 | + if (!responseData.isSuccess()){ | ||
| 96 | + opLog.setStatus("1"); | ||
| 97 | + opLog.setReponseResult(JSONUtils.obj2json(responseData)); | ||
| 98 | + return ResultBean.error(); | ||
| 99 | + } | ||
| 75 | //更新任务 | 100 | //更新任务 |
| 76 | streamTask.setDelayTime(delayParam.getDelaySecond()); | 101 | streamTask.setDelayTime(delayParam.getDelaySecond()); |
| 77 | streamTaskMapper.updateById(streamTask); | 102 | streamTaskMapper.updateById(streamTask); |
| 78 | } | 103 | } |
| 79 | if (streamTask.getPlayType().equals("play")){ | 104 | if (streamTask.getPlayType().equals("play")){ |
| 80 | - delayTask(streamTask.getTaskId(),delayParam.getDelayPlay()); | 105 | + ResponseData responseData = delayTask(streamTask.getTaskId(),delayParam.getDelayPlay()); |
| 106 | + if (!responseData.isSuccess()){ | ||
| 107 | + opLog.setStatus("1"); | ||
| 108 | + opLog.setReponseResult(JSONUtils.obj2json(responseData)); | ||
| 109 | + return ResultBean.error(); | ||
| 110 | + } | ||
| 81 | //更新任务 | 111 | //更新任务 |
| 82 | streamTask.setDelayTime(delayParam.getDelayPlay()); | 112 | streamTask.setDelayTime(delayParam.getDelayPlay()); |
| 83 | streamTaskMapper.updateById(streamTask); | 113 | streamTaskMapper.updateById(streamTask); |
| 84 | } | 114 | } |
| 85 | - }); | ||
| 86 | - | ||
| 87 | - //2.更新多画 | ||
| 88 | - | 115 | + } |
| 116 | + opLog.setStatus("0"); | ||
| 117 | + opLog.setReponseResult(JSONUtils.obj2json(ResponseData.ok())); | ||
| 118 | + operationLogService.save(opLog); | ||
| 89 | return ResultBean.ok("设置成功"); | 119 | return ResultBean.ok("设置成功"); |
| 90 | } | 120 | } |
| 91 | 121 | ||
| 92 | - public void delayTask(String taskId,int delayTime){ | 122 | + public ResponseData delayTask(String taskId, int delayTime){ |
| 93 | Map<String, Object> paramsMap = new HashMap<>(); | 123 | Map<String, Object> paramsMap = new HashMap<>(); |
| 94 | paramsMap.put("taskId", taskId); | 124 | paramsMap.put("taskId", taskId); |
| 95 | paramsMap.put("delayTime", delayTime); | 125 | paramsMap.put("delayTime", delayTime); |
| @@ -108,11 +138,14 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | @@ -108,11 +138,14 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | ||
| 108 | }else { | 138 | }else { |
| 109 | log.info("请求转码系统延时接口响应失败,response:{}",response); | 139 | log.info("请求转码系统延时接口响应失败,response:{}",response); |
| 110 | } | 140 | } |
| 141 | + return response; | ||
| 111 | } else { | 142 | } else { |
| 112 | log.error("请求转码系统延时接口失败,url:{},body:{}", delayTimeUrl, execute.body()); | 143 | log.error("请求转码系统延时接口失败,url:{},body:{}", delayTimeUrl, execute.body()); |
| 144 | + return ResponseData.error("请求转码系统延时接口失败"); | ||
| 113 | } | 145 | } |
| 114 | } catch (Exception e) { | 146 | } catch (Exception e) { |
| 115 | log.error("请求转码系统延时接口失败,url:{}", delayTimeUrl, e); | 147 | log.error("请求转码系统延时接口失败,url:{}", delayTimeUrl, e); |
| 148 | + return ResponseData.error("请求转码系统延时接口失败"); | ||
| 116 | } | 149 | } |
| 117 | } | 150 | } |
| 118 | 151 | ||
| @@ -139,6 +172,17 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | @@ -139,6 +172,17 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | ||
| 139 | return ResultBean.error("当前审片间没有播放任务"); | 172 | return ResultBean.error("当前审片间没有播放任务"); |
| 140 | } | 173 | } |
| 141 | 174 | ||
| 175 | + //日志 | ||
| 176 | + OperationLog opLog = new OperationLog(); | ||
| 177 | + opLog.setRoomName(liveMonitorRoom.getName()); | ||
| 178 | + opLog.setBusinessId(blockParam.getRoomId().toString()); | ||
| 179 | + opLog.setBusinessType("cloudMonitor"); | ||
| 180 | + opLog.setOperationType(blockParam.getBlockStatus().equals(0)? | ||
| 181 | + RoomOperationEnum.BLOCK.getCode():RoomOperationEnum.RECOVER.getCode()); | ||
| 182 | + opLog.setCreatedBy("admin"); | ||
| 183 | + opLog.setCreatedTime(LocalDateTime.now()); | ||
| 184 | + opLog.setRequestUrl(blockStatusUrl); | ||
| 185 | + | ||
| 142 | log.info("-->审片间屏蔽前置逻辑耗时:{}ms",System.currentTimeMillis()-start); | 186 | log.info("-->审片间屏蔽前置逻辑耗时:{}ms",System.currentTimeMillis()-start); |
| 143 | streamTasks.forEach(streamTask -> { | 187 | streamTasks.forEach(streamTask -> { |
| 144 | //调用屏蔽接口 | 188 | //调用屏蔽接口 |
| @@ -159,20 +203,31 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | @@ -159,20 +203,31 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | ||
| 159 | }); | 203 | }); |
| 160 | if (response.getResultCode().equals("0")) { | 204 | if (response.getResultCode().equals("0")) { |
| 161 | log.info("请求转码系统屏蔽/恢复接口成功"); | 205 | log.info("请求转码系统屏蔽/恢复接口成功"); |
| 206 | + if(streamTask.getTaskType().equals("0")){ | ||
| 207 | + opLog.setStatus(GlobalCodeEnum.SUCCESS.getCode()); | ||
| 208 | + opLog.setReponseResult(JSONUtils.obj2json(response)); | ||
| 209 | + } | ||
| 162 | }else { | 210 | }else { |
| 163 | log.info("请求转码系统屏蔽/恢复接口响应失败,response:{}",response); | 211 | log.info("请求转码系统屏蔽/恢复接口响应失败,response:{}",response); |
| 212 | + if(streamTask.getTaskType().equals("0")){ | ||
| 213 | + opLog.setStatus(GlobalCodeEnum.FAILURE.getCode()); | ||
| 214 | + opLog.setReponseResult(JSONUtils.obj2json(response)); | ||
| 215 | + } | ||
| 164 | throw new BusinessException("block_status_error", "屏蔽状态错误"); | 216 | throw new BusinessException("block_status_error", "屏蔽状态错误"); |
| 165 | } | 217 | } |
| 166 | } else { | 218 | } else { |
| 167 | log.error("请求转码系统屏蔽/恢复接口失败,url:{},body:{}", blockStatusUrl, execute.body()); | 219 | log.error("请求转码系统屏蔽/恢复接口失败,url:{},body:{}", blockStatusUrl, execute.body()); |
| 220 | + opLog.setStatus(GlobalCodeEnum.FAILURE.getCode()); | ||
| 168 | throw new BusinessException("block_status_error", "屏蔽状态错误"); | 221 | throw new BusinessException("block_status_error", "屏蔽状态错误"); |
| 169 | } | 222 | } |
| 170 | } catch (Exception e) { | 223 | } catch (Exception e) { |
| 171 | log.error("请求转码系统屏蔽/恢复接口失败,url:{}", blockStatusUrl, e); | 224 | log.error("请求转码系统屏蔽/恢复接口失败,url:{}", blockStatusUrl, e); |
| 225 | + opLog.setStatus(GlobalCodeEnum.FAILURE.getCode()); | ||
| 172 | throw new BusinessException("block_status_error", "屏蔽状态错误"); | 226 | throw new BusinessException("block_status_error", "屏蔽状态错误"); |
| 173 | } | 227 | } |
| 174 | }); | 228 | }); |
| 175 | - | 229 | + //保存操作日志 |
| 230 | + operationLogService.save(opLog); | ||
| 176 | //保存播控操作记录 | 231 | //保存播控操作记录 |
| 177 | MonitorMark monitorMark = new MonitorMark(); | 232 | MonitorMark monitorMark = new MonitorMark(); |
| 178 | monitorMark.setRoomId(blockParam.getRoomId()); | 233 | monitorMark.setRoomId(blockParam.getRoomId()); |
| @@ -207,6 +262,19 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | @@ -207,6 +262,19 @@ public class RoomOperationServiceImpl implements RoomOperationSerivice { | ||
| 207 | monitorMark.setOperationTime(markParam.getMarkTime()); | 262 | monitorMark.setOperationTime(markParam.getMarkTime()); |
| 208 | monitorMark.setCreatedBy("admin"); | 263 | monitorMark.setCreatedBy("admin"); |
| 209 | monitorMarkMapper.insert(monitorMark); | 264 | monitorMarkMapper.insert(monitorMark); |
| 265 | + //日志 | ||
| 266 | + OperationLog opLog = new OperationLog(); | ||
| 267 | + opLog.setRoomName(markParam.getRoomName()); | ||
| 268 | + opLog.setBusinessId(markParam.getRoomId().toString()); | ||
| 269 | + opLog.setBusinessType("cloudMonitor"); | ||
| 270 | + opLog.setOperationType(markParam.getOperationType()); | ||
| 271 | + opLog.setCreatedBy("admin"); | ||
| 272 | + opLog.setCreatedTime(LocalDateTime.now()); | ||
| 273 | + opLog.setRequestUrl(delayTimeUrl); | ||
| 274 | + opLog.setStatus("0"); | ||
| 275 | + operationLogService.save(opLog); | ||
| 276 | + | ||
| 277 | + | ||
| 210 | return ResultBean.ok(monitorMark); | 278 | return ResultBean.ok(monitorMark); |
| 211 | } | 279 | } |
| 212 | 280 |
-
Please register or login to post a comment