|
@@ -0,0 +1,107 @@
|
|
|
+package com.fdkankan.scene.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.scene.entity.SceneEditInfoExt;
|
|
|
+import com.fdkankan.scene.entity.ScenePlus;
|
|
|
+import com.fdkankan.scene.entity.Surveillance;
|
|
|
+import com.fdkankan.scene.mapper.ISurveillanceMapper;
|
|
|
+import com.fdkankan.scene.service.ISceneEditInfoExtService;
|
|
|
+import com.fdkankan.scene.service.IScenePlusService;
|
|
|
+import com.fdkankan.scene.service.ISurveillanceService;
|
|
|
+import com.fdkankan.scene.vo.BaseSidParamVO;
|
|
|
+import com.fdkankan.scene.vo.SurveillanceParamVO;
|
|
|
+import com.fdkankan.scene.vo.SurveillanceVO;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 监控推拉流信息 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2022-09-16
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class SurveillanceServiceImpl extends ServiceImpl<ISurveillanceMapper, Surveillance> implements ISurveillanceService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneEditInfoExtService sceneEditInfoExtService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData saveSurveillance(SurveillanceParamVO param) {
|
|
|
+
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
|
|
|
+
|
|
|
+ Surveillance surveillance = this.getBySid(param.getSid());
|
|
|
+ if(Objects.isNull(surveillance)){
|
|
|
+ surveillance = new Surveillance();
|
|
|
+ }
|
|
|
+ surveillance.setSid(param.getSid());
|
|
|
+ surveillance.setPanoId(param.getPanoId());
|
|
|
+ surveillance.setNum(param.getNum());
|
|
|
+ surveillance.setName(param.getName());
|
|
|
+ surveillance.setData(param.getData().toJSONString());
|
|
|
+ surveillance.setPlayUrl(param.getPlayUrl());
|
|
|
+ this.saveOrUpdate(surveillance);
|
|
|
+
|
|
|
+ sceneEditInfoExt.setSurveillances(CommonStatus.YES.code().intValue());
|
|
|
+ sceneEditInfoExtService.updateById(sceneEditInfoExt);
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData deleteSurveillance(BaseSidParamVO param) {
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
|
|
|
+
|
|
|
+ this.remove(new LambdaQueryWrapper<Surveillance>().eq(Surveillance::getSid, param.getSid()));
|
|
|
+
|
|
|
+ long count = this.count(new LambdaQueryWrapper<Surveillance>().eq(Surveillance::getNum, param.getNum()));
|
|
|
+ if(count < 1){
|
|
|
+ sceneEditInfoExt.setSurveillances(CommonStatus.NO.code().intValue());
|
|
|
+ }
|
|
|
+ sceneEditInfoExtService.updateById(sceneEditInfoExt);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SurveillanceVO> listSurveillance(String num) {
|
|
|
+ List<Surveillance> list = this.list(new LambdaQueryWrapper<Surveillance>().eq(Surveillance::getNum, num).orderByDesc(Surveillance::getId));
|
|
|
+ if(Objects.isNull(list)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<SurveillanceVO> voList = list.stream().map(item -> {
|
|
|
+ SurveillanceVO vo = BeanUtil.copyProperties(item, SurveillanceVO.class, "data");
|
|
|
+ vo.setData(JSON.parseObject(item.getData()));
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Surveillance getBySid(String sid) {
|
|
|
+ return this.getOne(new LambdaQueryWrapper<Surveillance>().eq(Surveillance::getSid, sid));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|