|  | @@ -2,6 +2,7 @@ package com.xunmei.mediator.api.video.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import cn.hutool.core.util.ObjectUtil;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson2.JSONObject;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 | 
	
	
		
			
				|  | @@ -23,7 +24,6 @@ import com.xunmei.mediator.api.video.mapper.VideoIntegrityCheckMapper;
 | 
	
		
			
				|  |  |  import com.xunmei.mediator.api.video.service.IVideoDaysCheckService;
 | 
	
		
			
				|  |  |  import com.xunmei.mediator.api.video.service.IVideoIntegrityCheckService;
 | 
	
		
			
				|  |  |  import com.xunmei.mediator.api.video.service.MediatorVideoIntegrityCheckLogService;
 | 
	
		
			
				|  |  | -import com.xunmei.mediator.domain.dto.redis.RedisKey;
 | 
	
		
			
				|  |  |  import com.xunmei.mediator.domain.dto.videoIntegrityCheck.VideoIntegrityCheckDto;
 | 
	
		
			
				|  |  |  import com.xunmei.mediator.domain.dto.videoIntegrityCheck.VideoIntegrityCheckReq;
 | 
	
		
			
				|  |  |  import com.xunmei.mediator.util.RedisUtil;
 | 
	
	
		
			
				|  | @@ -96,10 +96,11 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Object execute(WebsocketExecuteReq req) {
 | 
	
		
			
				|  |  | -        VideoIntegrityCheckDto checkDto = transform(req.getData());
 | 
	
		
			
				|  |  | +        String jsonString = JSON.toJSONString(req.getData());
 | 
	
		
			
				|  |  | +        VideoIntegrityCheckDto checkDto = transform(JSON.parseObject(jsonString, VideoIntegrityCheckReq.class));
 | 
	
		
			
				|  |  |          SysOrg sysOrg = iotServerInfoService.selectOrgByToken(req.getToken());
 | 
	
		
			
				|  |  |          checkDto.setOrganizationGuid(sysOrg.getCode());
 | 
	
		
			
				|  |  | -        this.saveData(checkDto,"");
 | 
	
		
			
				|  |  | +        this.saveData(checkDto, "");
 | 
	
		
			
				|  |  |          return "";
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -110,7 +111,7 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |          websocketResult.setTimestamp(new Date());
 | 
	
		
			
				|  |  |          HashMap<String, Object> hashMap = new HashMap<>();
 | 
	
		
			
				|  |  |          hashMap.put(WebSocketConstants.SERVICE, WebSocketConstants.GET_RECORD_INFOS_SERVICES);
 | 
	
		
			
				|  |  | -        hashMap.put(WebSocketConstants.ARGS,new  JSONObject());
 | 
	
		
			
				|  |  | +        hashMap.put(WebSocketConstants.ARGS, new JSONObject());
 | 
	
		
			
				|  |  |          websocketResult.setPayload(hashMap);
 | 
	
		
			
				|  |  |          WebSocketSessionHolder.sendAll(JacksonUtils.toJSONString(websocketResult));
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -118,12 +119,13 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public VideoIntegrityCheckDto transform(Object data) {
 | 
	
		
			
				|  |  | -        VideoIntegrityCheckReq req = (VideoIntegrityCheckReq)data;
 | 
	
		
			
				|  |  | +        VideoIntegrityCheckReq req = (VideoIntegrityCheckReq) data;
 | 
	
		
			
				|  |  |          VideoIntegrityCheckDto dst = new VideoIntegrityCheckDto();
 | 
	
		
			
				|  |  |          dst.setEquipmentCode(req.getDvsCode());
 | 
	
		
			
				|  |  |          dst.setChannelCode(req.getIndex());
 | 
	
		
			
				|  |  |          dst.setRecordDate(req.getRecordDate());
 | 
	
		
			
				|  |  |          dst.setLoseSpan(req.getLoseSpan());
 | 
	
		
			
				|  |  | +        dst.setRecordSpan(req.getRecordSpan());
 | 
	
		
			
				|  |  |          dst.setCheckSpan(req.getCheckSpan());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return dst;
 | 
	
	
		
			
				|  | @@ -137,9 +139,9 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |              return ReceiveErrorDto.error(msg);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //与上次接收到的数据进行比较,如果相同则不进行处理
 | 
	
		
			
				|  |  | -        if (redisUtil.compareWithCache(videoIntegrityCheckDto)) {
 | 
	
		
			
				|  |  | +        /*if (redisUtil.compareWithCache(videoIntegrityCheckDto)) {
 | 
	
		
			
				|  |  |              return ReceiveErrorDto.error(RedisKey.REPORT_DATA_REFUSE_MSG);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        }*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          String organizationGuid = videoIntegrityCheckDto.getOrganizationGuid();
 | 
	
		
			
				|  |  |          SysOrg org = orgService.findByCode(organizationGuid, SecurityConstants.INNER);
 | 
	
	
		
			
				|  | @@ -188,15 +190,17 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setChannelCode(videoIntegrityCheckDto.getChannelCode());
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setChannelName(videoIntegrityCheckDto.getChannelName());
 | 
	
		
			
				|  |  | -        videoIntegrityCheck.setCheckSpan(JSON.toJSONString(videoIntegrityCheckDto.getCheckSpan()));
 | 
	
		
			
				|  |  | +        videoIntegrityCheck.setCheckSpan(dealSpan(videoIntegrityCheckDto.getCheckSpan()));
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setEquipmentCode(videoIntegrityCheckDto.getEquipmentCode());
 | 
	
		
			
				|  |  | -        videoIntegrityCheck.setLoseSpan(JSON.toJSONString(videoIntegrityCheckDto.getLoseSpan()));
 | 
	
		
			
				|  |  | +        videoIntegrityCheck.setLoseSpan(dealSpan(videoIntegrityCheckDto.getLoseSpan()));
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setRecordDate(LocalDate.parse(videoIntegrityCheckDto.getRecordDate(), DateTimeFormatter.ISO_LOCAL_DATE));
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setOrgId(org.getId());
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setOrgName(org.getShortName());
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setOrgPath(org.getPath());
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setStatus(getStatus(videoIntegrityCheckDto));
 | 
	
		
			
				|  |  |          videoIntegrityCheck.setLoseDuration(calculateLoseMinute(videoIntegrityCheck.getLoseSpan()));
 | 
	
		
			
				|  |  | +        videoIntegrityCheck.setRecordType(videoIntegrityCheckDto.getRecordType());
 | 
	
		
			
				|  |  | +        videoIntegrityCheck.setRecordSpan(dealSpan(videoIntegrityCheckDto.getRecordSpan()));
 | 
	
		
			
				|  |  |          if (!isCompensate) {
 | 
	
		
			
				|  |  |              //不是补录才进行保存数据
 | 
	
		
			
				|  |  |              this.saveOrUpdate(videoIntegrityCheck);
 | 
	
	
		
			
				|  | @@ -206,6 +210,21 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |          return ReceiveErrorDto.success();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    //重新转换一次,之前的转换出来有转义符
 | 
	
		
			
				|  |  | +    private String dealSpan(List<String> spanList) {
 | 
	
		
			
				|  |  | +        List<JSONObject> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (String string : spanList) {
 | 
	
		
			
				|  |  | +            Map parse = JSON.parseObject(string, Map.class);
 | 
	
		
			
				|  |  | +            if (parse.get("st") != null && parse.get("et") != null) {
 | 
	
		
			
				|  |  | +                JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  | +                jsonObject.put("st", parse.get("st"));
 | 
	
		
			
				|  |  | +                jsonObject.put("et", parse.get("et"));
 | 
	
		
			
				|  |  | +                list.add(jsonObject);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return JSON.toJSONString(list);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void saveLog(MediatorVideoIntegrityCheck videoIntegrityCheck) {
 | 
	
		
			
				|  |  |          MediatorVideoIntegrityCheckLog newLog = new MediatorVideoIntegrityCheckLog();
 | 
	
		
			
				|  |  |          MediatorVideoIntegrityCheckLog logData = integrityCheckLogService.findByOrgIdAndEquipmentCodeAndChannelCode(videoIntegrityCheck.getOrgId(), videoIntegrityCheck.getEquipmentCode(), videoIntegrityCheck.getChannelCode(), videoIntegrityCheck.getRecordDate());
 | 
	
	
		
			
				|  | @@ -228,16 +247,19 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |          if (ObjectUtil.isEmpty(loseSpan)) {
 | 
	
		
			
				|  |  |              return 0;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        final List<Map> mapList = JSON.parseArray(loseSpan, Map.class);
 | 
	
		
			
				|  |  | -        int min = 0;
 | 
	
		
			
				|  |  | -        for (Map map : mapList) {
 | 
	
		
			
				|  |  | -            final String st = (String) map.get("st");
 | 
	
		
			
				|  |  | -            final String et = (String) map.get("et");
 | 
	
		
			
				|  |  | -            final LocalTime startTime = LocalTime.parse(st);
 | 
	
		
			
				|  |  | -            final LocalTime endTime = LocalTime.parse(et);
 | 
	
		
			
				|  |  | -            final long l = ChronoUnit.MINUTES.between(startTime, endTime);
 | 
	
		
			
				|  |  | -            min += l;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        JSONArray array = JSON.parseArray(loseSpan);
 | 
	
		
			
				|  |  | +        int min = 0;
 | 
	
		
			
				|  |  | +        for (Object object : array) {
 | 
	
		
			
				|  |  | +            if (object instanceof String) {
 | 
	
		
			
				|  |  | +                Map map = JSON.parseObject(object.toString(), Map.class);
 | 
	
		
			
				|  |  | +                final String st = (String) map.get("st");
 | 
	
		
			
				|  |  | +                final String et = (String) map.get("et");
 | 
	
		
			
				|  |  | +                final LocalTime startTime = LocalTime.parse(st);
 | 
	
		
			
				|  |  | +                final LocalTime endTime = LocalTime.parse(et);
 | 
	
		
			
				|  |  | +                final long l = ChronoUnit.MINUTES.between(startTime, endTime);
 | 
	
		
			
				|  |  | +                min += (int) l;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return min;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -255,9 +277,9 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
 | 
	
		
			
				|  |  |              return "channelCode 为空";
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if (StringUtils.isEmpty(videoIntegrityCheckDto.getChannelName())) {
 | 
	
		
			
				|  |  | +        /*if (StringUtils.isEmpty(videoIntegrityCheckDto.getChannelName())) {
 | 
	
		
			
				|  |  |              return "channelName 为空";
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        }*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (StringUtils.isEmpty(videoIntegrityCheckDto.getRecordDate())) {
 | 
	
		
			
				|  |  |              return "recordDate 为空";
 |