浏览代码

运营服务

hym 4 年之前
父节点
当前提交
859debfd6c
共有 25 个文件被更改,包括 677 次插入66 次删除
  1. 11 0
      smartcity-common/src/main/java/com/zcxk/common/model/Pagination.java
  2. 3 0
      smartcity-common/src/main/java/com/zcxk/common/model/ResultStatus.java
  3. 2 2
      smartcity-common/src/main/java/com/zcxk/common/utils/UserUtil.java
  4. 41 8
      smartcity-facilities/src/main/java/com/zcxk/facilities/controller/CameraController.java
  5. 5 8
      smartcity-facilities/src/main/java/com/zcxk/facilities/controller/FacilitiesEntityController.java
  6. 7 5
      smartcity-facilities/src/main/java/com/zcxk/facilities/controller/MonitorPointController.java
  7. 3 1
      smartcity-facilities/src/main/java/com/zcxk/facilities/controller/MonitorSceneController.java
  8. 84 0
      smartcity-facilities/src/main/java/com/zcxk/facilities/dao/ManufacturerMapper.java
  9. 4 1
      smartcity-facilities/src/main/java/com/zcxk/facilities/dao/MonitorPointMapper.java
  10. 1 0
      smartcity-facilities/src/main/java/com/zcxk/facilities/dao/MonitorSceneMapper.java
  11. 7 1
      smartcity-facilities/src/main/java/com/zcxk/facilities/dto/CameraDTO.java
  12. 14 0
      smartcity-facilities/src/main/java/com/zcxk/facilities/dto/CameraTreeDTO.java
  13. 5 0
      smartcity-facilities/src/main/java/com/zcxk/facilities/dto/VideoRecorderDTO.java
  14. 47 0
      smartcity-facilities/src/main/java/com/zcxk/facilities/entity/CameraSaveInfoDTO.java
  15. 60 0
      smartcity-facilities/src/main/java/com/zcxk/facilities/entity/Manufacturer.java
  16. 9 0
      smartcity-facilities/src/main/java/com/zcxk/facilities/entity/Platform.java
  17. 14 5
      smartcity-facilities/src/main/java/com/zcxk/facilities/service/CameraService.java
  18. 2 2
      smartcity-facilities/src/main/java/com/zcxk/facilities/service/MonitorPointService.java
  19. 142 17
      smartcity-facilities/src/main/java/com/zcxk/facilities/service/impl/CameraServiceImpl.java
  20. 26 13
      smartcity-facilities/src/main/java/com/zcxk/facilities/service/impl/MonitorPointServiceImpl.java
  21. 6 1
      smartcity-facilities/src/main/java/com/zcxk/facilities/service/impl/MonitorSceneServiceImpl.java
  22. 1 1
      smartcity-facilities/src/main/resources/mapper/CameraMapper.xml
  23. 158 0
      smartcity-facilities/src/main/resources/mapper/ManufacturerMapper.xml
  24. 12 1
      smartcity-facilities/src/main/resources/mapper/MonitorPointMapper.xml
  25. 13 0
      smartcity-facilities/src/main/resources/mapper/MonitorSceneMapper.xml

+ 11 - 0
smartcity-common/src/main/java/com/zcxk/common/model/Pagination.java

@@ -1,6 +1,7 @@
 package com.zcxk.common.model;
 
 import com.github.pagehelper.Page;
+import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -35,4 +36,14 @@ public class Pagination<T> implements Serializable {
         this.list = page;
         this.total = page.getTotal();
     }
+    /**
+     * 包装Page对象
+     *
+     * @param pageInfo
+     */
+    public Pagination(PageInfo pageInfo) {
+
+        this.list = pageInfo.getList();
+        this.total = pageInfo.getTotal();
+    }
 }

+ 3 - 0
smartcity-common/src/main/java/com/zcxk/common/model/ResultStatus.java

@@ -99,6 +99,9 @@ public enum ResultStatus {
     PHONE_NUMBER_NOT_FOUND_WECHAT_ERROR(900014, "您微信绑定的手机号尚未注册,请使用平台注册账号进行登录。"),
 
     SYSTEM_ERROR(999999, "系统错误"),
+    //600
+    SCENCE_NAME_ALREADY_EXISTS(600001,"该场景名称已存在"),
+    POINT_NAME_ALREADY_EXISTS(600002,"该监控点名称已存在"),
     ;
 
     private final int status;

+ 2 - 2
smartcity-common/src/main/java/com/zcxk/common/utils/UserUtil.java

@@ -21,7 +21,7 @@ public class UserUtil {
         Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
         if (authentication != null) {
             if (authentication instanceof AnonymousAuthenticationToken) {
-                return null;
+                return new LoginUser(null);
             }
 
             if (authentication instanceof UsernamePasswordAuthenticationToken) {
@@ -55,6 +55,6 @@ public class UserUtil {
             }
         }
 
-        return null;
+        return new LoginUser(null);
     }
 }

+ 41 - 8
smartcity-facilities/src/main/java/com/zcxk/facilities/controller/CameraController.java

@@ -1,14 +1,15 @@
 package com.zcxk.facilities.controller;
 
 import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.google.common.collect.Maps;
 import com.zcxk.common.model.AjaxMessage;
 import com.zcxk.common.model.Pagination;
 import com.zcxk.common.model.ResultStatus;
-import com.zcxk.facilities.dto.CameraDTO;
-import com.zcxk.facilities.dto.ChannelDTO;
-import com.zcxk.facilities.dto.PanTiltDTO;
-import com.zcxk.facilities.dto.VideoRecorderDTO;
+import com.zcxk.facilities.dto.*;
 import com.zcxk.facilities.entity.Camera;
+import com.zcxk.facilities.entity.Manufacturer;
+import com.zcxk.facilities.entity.Platform;
 import com.zcxk.facilities.service.CameraService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -16,7 +17,9 @@ import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * (Camera)控制层
@@ -105,12 +108,18 @@ public class CameraController {
     public AjaxMessage<Pagination<Camera>> selectPage(
             @RequestParam Integer pageNum,
             @RequestParam Integer pageSize,
-            @RequestParam(required = false)Integer monitorPointId) {
+            @RequestParam(required = false)Integer monitorPointId,
+            @RequestParam(required = false)Integer monitorSceneId) {
         Camera camera = new Camera();
         camera.setMonitorPointId(monitorPointId);
+        camera.setMonitorSceneId(monitorSceneId);
         PageHelper.startPage(pageNum, pageSize);
-        List<Camera> cameras = cameraService.selectPage(camera);
-        Pagination<Camera> pages = new Pagination<>(cameras);
+        PageInfo<Camera> pageInfo = cameraService.selectPage(camera);
+        Pagination<Camera>pages=new Pagination<>(pageInfo);
+
+
+
+
         return new AjaxMessage<>(ResultStatus.OK, pages);
     }
 
@@ -122,7 +131,7 @@ public class CameraController {
      * @return Response对象
      */
     @RequestMapping(value = "selectList", method = RequestMethod.POST)
-    @ApiOperation(value = "查询摄像头列表(地图)")
+    @ApiOperation(value = "查询摄像头列表",notes = "地图上悬浮列表,添加缩略下拉列表,查看站点已有摄像头列表")
     public AjaxMessage<List<Camera>> selectList(@RequestParam  Integer monitorPointId,@RequestParam Boolean refreshFlag) {
         Camera camera = new Camera();
         camera.setMonitorPointId(monitorPointId);
@@ -182,5 +191,29 @@ public class CameraController {
         cameraService.syncStatus();
         return new AjaxMessage<>(ResultStatus.OK);
     }*/
+    @RequestMapping(value = "getManufacturer", method = RequestMethod.GET)
+    @ApiOperation(value = "操控云台")
+    public AjaxMessage<List<Manufacturer>>getManufacturer() {
+
+        List<Manufacturer>manufacturer=cameraService.getManufacturer();
+
+        return new AjaxMessage<>(ResultStatus.OK, manufacturer);
+    }
+    @RequestMapping(value = "getPlatform", method = RequestMethod.GET)
+    @ApiOperation(value = "getPlatform")
+    public AjaxMessage<List<Platform> > getPlatform() {
+
+        List<Platform>platform=cameraService.getPlatform();
+
+        return new AjaxMessage<>(ResultStatus.OK, platform);
+    }
+    @RequestMapping(value = "getTree", method = RequestMethod.GET)
+    @ApiOperation(value = "getTree")
+    public AjaxMessage<List<CameraTreeDTO> > getTree() {
+
+        List<CameraTreeDTO>cameraTreeDTOS=cameraService.getTree();
+
+        return new AjaxMessage<>(ResultStatus.OK, cameraTreeDTOS);
+    }
 
 }

+ 5 - 8
smartcity-facilities/src/main/java/com/zcxk/facilities/controller/FacilitiesEntityController.java

@@ -10,10 +10,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -24,7 +21,7 @@ import java.util.List;
  * @since 2020-09-30 17:59:15
  */
 @RestController
-@RequestMapping("/facilities/entity")
+@RequestMapping("/entity")
 @Api(tags = "")
 public class FacilitiesEntityController {
     /**
@@ -99,9 +96,9 @@ public class FacilitiesEntityController {
      */
     @RequestMapping(value = "selectPage", method = RequestMethod.POST)
     @ApiOperation(value = "查询设施列表分页")
-    public AjaxMessage<Pagination<FacilitiesEntity>> selectPage(@ApiParam(value = "页数", required = true)Integer pageNum,
-                                                                @ApiParam(value = "每页行数", required = true)Integer pageSize,
-                                                                @ApiParam(value = "设施类型id", required = true)Integer facilitiesConfigId) {
+    public AjaxMessage<Pagination<FacilitiesEntity>> selectPage(@ApiParam(value = "页数", required = true)@RequestParam Integer pageNum,
+                                                                @ApiParam(value = "每页行数", required = true)@RequestParam Integer pageSize,
+                                                                @ApiParam(value = "设施类型id", required = false)@RequestParam Integer facilitiesConfigId) {
         FacilitiesEntity facilitiesEntity = new FacilitiesEntity();
         facilitiesEntity.setFacilitiesConfigId(facilitiesConfigId);
         PageHelper.startPage(pageNum, pageSize);

+ 7 - 5
smartcity-facilities/src/main/java/com/zcxk/facilities/controller/MonitorPointController.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
 import com.zcxk.common.model.AjaxMessage;
 import com.zcxk.common.model.Pagination;
 import com.zcxk.common.model.ResultStatus;
+import com.zcxk.facilities.dto.CameraTreeDTO;
 import com.zcxk.facilities.dto.MonitorPointTreeDTO;
 import com.zcxk.facilities.entity.MonitorPoint;
 import com.zcxk.facilities.service.MonitorPointService;
@@ -44,7 +45,9 @@ public class MonitorPointController {
     @ApiOperation(value = "增加监控点")
     public AjaxMessage<Integer> insert(@ApiParam(value = "监控点实体", required = true) @RequestBody MonitorPoint monitorPoint) {
         int result = monitorPointService.insert(monitorPoint);
-
+        if(result==-1){
+            return new AjaxMessage<>(ResultStatus.POINT_NAME_ALREADY_EXISTS, result);
+        }
         return new AjaxMessage<>(ResultStatus.OK, result);
     }
 
@@ -86,13 +89,12 @@ public class MonitorPointController {
      */
     @RequestMapping(value = "selectTree", method = RequestMethod.GET)
     @ApiOperation(value = "查询监控树")
-    public AjaxMessage<List<MonitorPointTreeDTO>> selectTree() {
-
+    public AjaxMessage<List<CameraTreeDTO>> selectTree() {
 
 
-        List<MonitorPointTreeDTO> monitorPoints = monitorPointService.selectTree();
+        List<CameraTreeDTO> cameraTreeDTOS = monitorPointService.selectTree();
 
-        return new AjaxMessage<>(ResultStatus.OK, monitorPoints);
+        return new AjaxMessage<>(ResultStatus.OK, cameraTreeDTOS);
     }
     /**
      * 监控树

+ 3 - 1
smartcity-facilities/src/main/java/com/zcxk/facilities/controller/MonitorSceneController.java

@@ -42,7 +42,9 @@ public class MonitorSceneController {
     @ApiOperation(value = "新增监控场景")
     public AjaxMessage<Integer> insert(@ApiParam(value = "监控场景", required = true) @RequestBody MonitorScene monitorScene) {
         int result = monitorSceneService.insert(monitorScene);
-
+        if(result==-1){
+            return new AjaxMessage<>(ResultStatus.SCENCE_NAME_ALREADY_EXISTS, result);
+        }
         return new AjaxMessage<>(ResultStatus.OK, result);
     }
 

+ 84 - 0
smartcity-facilities/src/main/java/com/zcxk/facilities/dao/ManufacturerMapper.java

@@ -0,0 +1,84 @@
+package com.zcxk.facilities.dao;
+
+
+import com.zcxk.facilities.entity.Manufacturer;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 厂商(Manufacturer)表数据库访问层
+ *
+ * @author hym
+ * @since 2020-12-08 09:53:30
+ */
+@Mapper
+public interface ManufacturerMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    Manufacturer selectById(Integer id);
+
+
+    /**
+     * 查询全部
+     *
+     * @return 对象列表
+     */
+    List<Manufacturer> selectAll();
+
+    /**
+     * 通过实体作为筛选条件查询
+     *
+     * @param manufacturer 实例对象
+     * @return 对象列表
+     */
+    List<Manufacturer> selectList(Manufacturer manufacturer);
+
+    /**
+     * 新增数据
+     *
+     * @param manufacturer 实例对象
+     * @return 影响行数
+     */
+    int insert(Manufacturer manufacturer);
+
+    /**
+     * 批量新增
+     *
+     * @param manufacturers 实例对象的集合
+     * @return 影响行数
+     */
+    int batchInsert(@Param("manufacturers") List<Manufacturer> manufacturers);
+
+    /**
+     * 修改数据
+     *
+     * @param manufacturer 实例对象
+     * @return 影响行数
+     */
+    int update(Manufacturer manufacturer);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+    /**
+     * 查询总数据数
+     *
+     * @return 数据总数
+     */
+    int count();
+
+
+
+}

+ 4 - 1
smartcity-facilities/src/main/java/com/zcxk/facilities/dao/MonitorPointMapper.java

@@ -4,6 +4,7 @@ import com.zcxk.facilities.dto.MonitorPointTreeDTO;
 import com.zcxk.facilities.entity.MonitorPoint;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.security.access.method.P;
 
 import java.util.List;
 
@@ -80,5 +81,7 @@ public interface MonitorPointMapper {
     int count();
 
 
-    List<MonitorPointTreeDTO> selectTree(Integer siteId);
+    List<MonitorPointTreeDTO> selectTree(@Param("siteId") Integer siteId);
+
+    MonitorPoint queryByName(@Param("monitorPointName") String monitorPointName);
 }

+ 1 - 0
smartcity-facilities/src/main/java/com/zcxk/facilities/dao/MonitorSceneMapper.java

@@ -81,4 +81,5 @@ public interface MonitorSceneMapper {
 
     int deleteAllPoints(Integer id);
 
+    MonitorScene queryByName(@Param("monitorSceneName") String monitorSceneName);
 }

+ 7 - 1
smartcity-facilities/src/main/java/com/zcxk/facilities/dto/CameraDTO.java

@@ -1,6 +1,7 @@
 package com.zcxk.facilities.dto;
 
 import com.zcxk.facilities.entity.Camera;
+import com.zcxk.facilities.entity.CameraSaveInfoDTO;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -17,10 +18,15 @@ public class CameraDTO {
      * 摄像头信息
      */
     @ApiModelProperty(value = "摄像头信息")
-    private List<Camera> cameras;
+    private List<CameraSaveInfoDTO> cameras;
     @ApiModelProperty(value = "场景id")
     private Integer senceId;
     @ApiModelProperty(value = "监控点id")
     private Integer pointId;
+    /**
+     * 摄像头信息
+     */
+    @ApiModelProperty(value = "摄像头信息",hidden = true)
+    private List<Camera> saveCameras;
 
 }

+ 14 - 0
smartcity-facilities/src/main/java/com/zcxk/facilities/dto/CameraTreeDTO.java

@@ -0,0 +1,14 @@
+package com.zcxk.facilities.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CameraTreeDTO {
+    private Integer id;
+    private String name;
+    private Integer size;
+    private String parentName;
+    private List<CameraTreeDTO>child;
+}

+ 5 - 0
smartcity-facilities/src/main/java/com/zcxk/facilities/dto/VideoRecorderDTO.java

@@ -35,5 +35,10 @@ public class VideoRecorderDTO {
      */
     @ApiModelProperty(value = "验证码")
     private String verificationCode;
+    /**
+     * 监测点
+     */
+    @ApiModelProperty(value = "监测点")
+    private Integer pointId;
 
 }

+ 47 - 0
smartcity-facilities/src/main/java/com/zcxk/facilities/entity/CameraSaveInfoDTO.java

@@ -0,0 +1,47 @@
+package com.zcxk.facilities.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * (Camera)实体类
+ *
+ * @author hym
+ * @since 2020-12-03 14:25:35
+ */
+@Data
+@ApiModel
+public class CameraSaveInfoDTO implements Serializable {
+    private static final long serialVersionUID = -33591844896492203L;
+
+    /**
+     * 通道号
+     */
+    @ApiModelProperty(value = "通道号")
+    private Integer channelNo;
+    /**
+     * 通道名称
+     */
+    @ApiModelProperty(value = "通道名称")
+    private String channelName;
+    /**
+     * 通道序列号
+     */
+    @ApiModelProperty(value = "通道序列号")
+    private String ipcSerial;
+    /**
+     * 通道号
+     */
+    @ApiModelProperty(value = "通道状态")
+    private Integer status;
+
+
+
+
+}

+ 60 - 0
smartcity-facilities/src/main/java/com/zcxk/facilities/entity/Manufacturer.java

@@ -0,0 +1,60 @@
+package com.zcxk.facilities.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 厂商(Manufacturer)实体类
+ *
+ * @author hym
+ * @since 2020-12-08 09:53:30
+ */
+@Data
+@ApiModel
+public class Manufacturer implements Serializable {
+    private static final long serialVersionUID = -47048600494626650L;
+    /**
+     * id
+     */
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * 名称
+     */
+    @ApiModelProperty(value = "名称")
+    private String name;
+    /**
+     * 类型
+     */
+    @ApiModelProperty(value = "类型")
+    private Integer type;
+    /**
+     * 状态
+     */
+    @ApiModelProperty(value = "状态")
+    private Integer status;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createDate;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间")
+    private Date updateDate;
+    /**
+     * 更新人
+     */
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+}

+ 9 - 0
smartcity-facilities/src/main/java/com/zcxk/facilities/entity/Platform.java

@@ -0,0 +1,9 @@
+package com.zcxk.facilities.entity;
+
+import lombok.Data;
+
+@Data
+public class Platform {
+    private Integer id;
+    private String name;
+}

+ 14 - 5
smartcity-facilities/src/main/java/com/zcxk/facilities/service/CameraService.java

@@ -1,12 +1,13 @@
 package com.zcxk.facilities.service;
 
-import com.zcxk.facilities.dto.CameraDTO;
-import com.zcxk.facilities.dto.ChannelDTO;
-import com.zcxk.facilities.dto.PanTiltDTO;
-import com.zcxk.facilities.dto.VideoRecorderDTO;
+import com.github.pagehelper.PageInfo;
+import com.zcxk.facilities.dto.*;
 import com.zcxk.facilities.entity.Camera;
+import com.zcxk.facilities.entity.Manufacturer;
+import com.zcxk.facilities.entity.Platform;
 
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -88,8 +89,16 @@ public interface CameraService {
 
     List<Camera> findVideoRecorderInfo(VideoRecorderDTO videoRecorderDTO);
 
-    List<Camera> selectPage(Camera camera);
+    PageInfo selectPage(Camera camera);
     void capture();
     void syncStatus();
 
+    List<Manufacturer> getManufacturer();
+
+
+    List<Platform> getPlatform();
+
+    List<CameraTreeDTO> getTree();
+
+
 }

+ 2 - 2
smartcity-facilities/src/main/java/com/zcxk/facilities/service/MonitorPointService.java

@@ -1,6 +1,6 @@
 package com.zcxk.facilities.service;
 
-import com.zcxk.facilities.dto.MonitorPointTreeDTO;
+import com.zcxk.facilities.dto.CameraTreeDTO;
 import com.zcxk.facilities.entity.MonitorPoint;
 
 import java.util.List;
@@ -77,7 +77,7 @@ public interface MonitorPointService {
      */
     int count();
 
-    List<MonitorPointTreeDTO> selectTree();
+    List<CameraTreeDTO> selectTree();
 
     int sorted(List<Integer> ids);
 

+ 142 - 17
smartcity-facilities/src/main/java/com/zcxk/facilities/service/impl/CameraServiceImpl.java

@@ -2,19 +2,22 @@ package com.zcxk.facilities.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.zcxk.common.entity.LoginUser;
-import com.zcxk.facilities.dto.ChannelDTO;
+import com.zcxk.facilities.dao.ManufacturerMapper;
+import com.zcxk.facilities.dao.MonitorPointMapper;
+import com.zcxk.facilities.dao.MonitorSceneMapper;
+import com.zcxk.facilities.dto.*;
+import com.zcxk.facilities.entity.*;
 import com.zcxk.facilities.uitls.RedisUtil;
 import com.zcxk.common.utils.UserUtil;
 import com.zcxk.facilities.dao.CameraMapper;
-import com.zcxk.facilities.dto.CameraDTO;
-import com.zcxk.facilities.dto.PanTiltDTO;
-import com.zcxk.facilities.dto.VideoRecorderDTO;
-import com.zcxk.facilities.entity.Camera;
 import com.zcxk.facilities.service.CameraService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -45,6 +48,12 @@ public class CameraServiceImpl implements CameraService {
     @Autowired
     private RedisUtil redisUtil;
     private String getTokenUrl="https://open.ys7.com/api/lapp/token/get";
+    @Autowired
+    private ManufacturerMapper manufacturerMapper;
+    @Autowired
+    private MonitorSceneMapper monitorSceneMapper;
+    @Autowired
+    private MonitorPointMapper monitorPointMapper;
 
     /**
      * 通过ID查询单条数据
@@ -82,6 +91,7 @@ public class CameraServiceImpl implements CameraService {
     public List<Camera> selectList(Camera camera) {
         camera.setSiteId(UserUtil.getCurrentUser().getSiteId());
         List<Camera> cameras = this.cameraMapper.selectList(camera);
+        transferCamerInfo(cameras);
         if(camera.getRefreshFlag()){
             Map<String, List<Camera>> detailmap = cameras.stream()
                     .collect(Collectors.groupingBy(d -> d.getDeviceSerial()));
@@ -143,22 +153,30 @@ public class CameraServiceImpl implements CameraService {
      */
     @Override
     public int insert(CameraDTO cameraDTO) {
-        List<Camera> cameras = cameraDTO.getCameras();
+        List<CameraSaveInfoDTO> cameras = cameraDTO.getCameras();
         LoginUser currentUser = UserUtil.getCurrentUser();
         Integer siteId = currentUser.getSiteId();
         String username = currentUser.getUsername();
 
-        cameraMapper.unbindCameraRelations(cameraDTO.getPointId(),null);
+        //cameraMapper.unbindCameraRelations(cameraDTO.getPointId(),null);
+        List<Camera>saveCameras=new ArrayList<>();
         cameras.forEach(cameraInfo -> {
-            BeanUtils.copyProperties(cameraDTO.getVideoRecorderDTO(),cameraInfo);
-            cameraInfo.setSiteId(siteId);
-            cameraInfo.setCreateBy(username);
-            cameraInfo.setDateCreate(new Date());
-            cameraInfo.setMonitorPointId(cameraDTO.getPointId());
-            cameraInfo.setMonitorSceneId(cameraDTO.getSenceId());
-            cameraInfo.setStatus(1);
+            Camera camera=new Camera();
+            BeanUtils.copyProperties(cameraDTO.getVideoRecorderDTO(),camera);
+            BeanUtils.copyProperties(cameraInfo,camera);
+            camera.setSiteId(siteId);
+            camera.setCreateBy(username);
+            camera.setDateCreate(new Date());
+            camera.setMonitorPointId(cameraDTO.getPointId());
+            camera.setMonitorSceneId(cameraDTO.getSenceId());
+            camera.setStatus(1);
+            camera.setVideoStatus(1);
+            camera.setCameraStatus(cameraInfo.getStatus()
+            );
+            saveCameras.add(camera);
         });
-        syncChannelName(cameras);
+        syncChannelName(saveCameras);
+        cameraDTO.setSaveCameras(saveCameras);
         this.cameraMapper.batchInsert(cameraDTO);
         return 0;//;
     }
@@ -317,13 +335,50 @@ public class CameraServiceImpl implements CameraService {
 
             cameras= JSONArray.parseArray(info.getString("data"),Camera.class);
         }
+        Camera queryCamera=new Camera();
+        queryCamera.setMonitorPointId(videoRecorderDTO.getPointId());
+        List<Camera> selectedCamra = cameraMapper.selectList(queryCamera);
+        Map<String, Integer>map=new HashMap<>();
+        selectedCamra.forEach(c->{
+            map.put(c.getDeviceSerial()+"_"+c.getChannelNo(),1);
+        });
+        cameras= cameras.stream().filter(c->{
+            boolean flag=true;
+            if(map.get(c.getDeviceSerial()+"_"+c.getChannelNo())!=null){
+                flag=false;
+            }
+            return flag;
+        }).collect(Collectors.toList());
         return cameras;
     }
 
     @Override
-    public List<Camera> selectPage(Camera camera) {
+    public PageInfo selectPage(Camera camera) {
+        List<Manufacturer> manufacturer = getManufacturer();
+
+        List<Camera> cameras = cameraMapper.selectPage(camera);
+        PageInfo<Camera> pageInfo = new PageInfo(cameras);
+        transferCamerInfo(pageInfo.getList());
+        return pageInfo;
+    }
+    private void transferCamerInfo(List<Camera>info){
+        if(info.size()>0){
+            List<Manufacturer> manufacturer = getManufacturer();
+            Map<String,String>transfManufacturer=Maps.newHashMap();
+            manufacturer.forEach(m->{
+                transfManufacturer.put(m.getId()+"",m.getName());
+            });
+            List<Platform> platform = getPlatform();
+            Map<String,String>transfPlatform=Maps.newHashMap();
+            platform.forEach(p ->{
+                transfPlatform.put(p.getId()+"",p.getName());
+            });
+            info.forEach(c->{
+                c.setManufacturer(transfManufacturer.get(c.getManufacturer()));
+                c.setPlatform(transfManufacturer.get(c.getPlatform()));
+            });
+        }
 
-        return cameraMapper.selectPage(camera);
     }
 
     private void catureSevice(Camera camera, String captureUrl){
@@ -376,6 +431,76 @@ public class CameraServiceImpl implements CameraService {
         sycnCameraStatus(cameras,detailmap);
         sycnDeviceStatus(detailmap);
     }
+
+    @Override
+    public List<Manufacturer> getManufacturer() {
+        Manufacturer manufacturer=new Manufacturer();
+        manufacturer.setStatus(1);
+        manufacturer.setType(2);
+        return manufacturerMapper.selectList(manufacturer);
+    }
+
+    @Override
+    public List<Platform> getPlatform() {
+        List<Platform>platforms=new ArrayList<>();
+        Platform platform=new Platform();
+        platform.setId(1);
+        platform.setName("萤石云");
+        platforms.add(platform);
+        return platforms;
+    }
+    private List<CameraTreeDTO> getTree2(){
+        Camera camera=new Camera();
+        camera.setSiteId(UserUtil.getCurrentUser().getSiteId());
+        List<CameraTreeDTO>treeDTOS=new ArrayList<>();
+        List<Camera> cameras = cameraMapper.selectList(camera);
+
+        return treeDTOS;
+    }
+    @Override
+    public List<CameraTreeDTO> getTree() {
+        MonitorScene monitorScene=new MonitorScene();
+        Integer siteId = UserUtil.getCurrentUser().getSiteId();
+        monitorScene.setSiteId(siteId);
+        List<MonitorScene> monitorScenes = monitorSceneMapper.selectList(monitorScene);
+        MonitorPoint monitorPoint=new MonitorPoint();
+        monitorPoint.setSiteId(siteId);
+        List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(monitorPoint);
+        Camera camera=new Camera();
+        camera.setSiteId(siteId);
+        List<CameraTreeDTO>treeDTOS=new ArrayList<>();
+        List<Camera> cameras = cameraMapper.selectList(camera);
+        Map<Integer, List<MonitorPoint>> pointMap = monitorPoints.stream()
+                .collect(Collectors.groupingBy(d -> d.getMonitorSceneId()));
+        Map<Integer, List<Camera>> cameraMap = cameras.stream()
+                .collect(Collectors.groupingBy(d -> d.getMonitorPointId()));
+        monitorScenes.forEach(monitorSceneDto->{
+            CameraTreeDTO cameraTreeDTO=new CameraTreeDTO();
+            cameraTreeDTO.setName(monitorSceneDto.getMonitorSceneName());
+            cameraTreeDTO.setId(monitorSceneDto.getId());
+            List<MonitorPoint> monitorPointList = pointMap.get(cameraTreeDTO.getId());
+            List<CameraTreeDTO>treeSencond=new ArrayList<>();
+            monitorPointList.forEach(monitorPointInfo ->{
+                CameraTreeDTO sencond=new CameraTreeDTO();
+                sencond.setName(monitorPointInfo.getMonitorPointName());
+                sencond.setId(monitorPointInfo.getId());
+                List<CameraTreeDTO>treeThird=new ArrayList<>();
+                List<Camera> cameras2 = cameraMap.get(monitorPoint.getId());
+                cameras2.forEach(camera1 -> {
+                    CameraTreeDTO third=new CameraTreeDTO();
+                    third.setName(camera1.getChannelName());
+                    third.setId(camera1.getId());
+                    treeThird.add(third);
+                });
+                sencond.setChild(treeThird);
+                treeSencond.add(sencond);
+            } );
+            cameraTreeDTO.setChild(treeSencond);
+            treeDTOS.add(cameraTreeDTO);
+        });
+        return treeDTOS;
+    }
+
     private void sycnDeviceStatus( Map<String, List<Camera>> detailmap){
         Iterator<List<Camera>> iterator = detailmap.values().iterator();
          while(iterator.hasNext()){

+ 26 - 13
smartcity-facilities/src/main/java/com/zcxk/facilities/service/impl/MonitorPointServiceImpl.java

@@ -4,17 +4,14 @@ import com.zcxk.common.entity.LoginUser;
 import com.zcxk.common.utils.UserUtil;
 import com.zcxk.facilities.dao.CameraMapper;
 import com.zcxk.facilities.dao.MonitorPointMapper;
+import com.zcxk.facilities.dto.CameraTreeDTO;
 import com.zcxk.facilities.dto.MonitorPointTreeDTO;
 import com.zcxk.facilities.entity.MonitorPoint;
 import com.zcxk.facilities.service.MonitorPointService;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -76,7 +73,13 @@ public class MonitorPointServiceImpl implements MonitorPointService {
         monitorPoint.setCreateBy(currentUser.getUsername());
         monitorPoint.setSiteId(currentUser.getSiteId());
         monitorPoint.setStatus(1);
-        return this.monitorPointMapper.insert(monitorPoint);
+        MonitorPoint monitorPoint1 = monitorPointMapper.queryByName(monitorPoint.getMonitorPointName());
+        if(monitorPoint1!=null){
+            return -1;
+        }
+        this.monitorPointMapper.insert(monitorPoint);
+
+        return monitorPoint.getId();
     }
 
     /**
@@ -132,24 +135,34 @@ public class MonitorPointServiceImpl implements MonitorPointService {
     }
 
     @Override
-    public List<MonitorPointTreeDTO> selectTree() {
+    public List<CameraTreeDTO> selectTree() {
         List<MonitorPointTreeDTO> trees=
                 monitorPointMapper.selectTree(UserUtil.getCurrentUser().getSiteId());
         Map<Integer, List<MonitorPointTreeDTO>> detailmap = trees.stream()
                 .collect(Collectors.groupingBy(d -> d.getMonitorSceneId() ));
         Iterator<List<MonitorPointTreeDTO>> iterator = detailmap.values().iterator();
         trees.clear();
+        List<CameraTreeDTO>newTress=new ArrayList<>();
         while (iterator.hasNext()){
             List<MonitorPointTreeDTO> next = iterator.next();
-            MonitorPointTreeDTO monitorPointTreeDTO=new MonitorPointTreeDTO();
-            BeanUtils.copyProperties(next.get(0),monitorPointTreeDTO);
-            monitorPointTreeDTO.setMonitorPointTrees(next);
-            monitorPointTreeDTO.setSize(next.size());
-            trees.add(monitorPointTreeDTO);
+            CameraTreeDTO cameraTreeDTO=new CameraTreeDTO();
+            MonitorPointTreeDTO monitorPointTreeDTO = next.get(0);
+            cameraTreeDTO.setId(monitorPointTreeDTO.getMonitorSceneId());
+            cameraTreeDTO.setName(monitorPointTreeDTO.getMonitorSceneName());
+            List<CameraTreeDTO>cameraTreeDTOS=new ArrayList<>();
+            next.forEach(n->{
+                CameraTreeDTO cameraTreeDTOChild=new CameraTreeDTO();
+                cameraTreeDTOChild.setId(n.getMonitorPointId());
+                cameraTreeDTOChild.setName(n.getMonitorPointName());
+                cameraTreeDTOS.add(cameraTreeDTOChild);
+            });
+            cameraTreeDTO.setChild(cameraTreeDTOS);
+            cameraTreeDTO.setSize(cameraTreeDTOS.size());
+            newTress.add(cameraTreeDTO);
 
         }
 
-        return  trees;
+        return  newTress;
     }
 
     @Override

+ 6 - 1
smartcity-facilities/src/main/java/com/zcxk/facilities/service/impl/MonitorSceneServiceImpl.java

@@ -72,7 +72,12 @@ public class MonitorSceneServiceImpl implements MonitorSceneService {
         monitorScene.setCreateBy(currentUser.getUsername());
         monitorScene.setSiteId(currentUser.getSiteId());
         monitorScene.setStatus(1);
-        return this.monitorSceneMapper.insert(monitorScene);
+        MonitorScene monitorScene1 = monitorSceneMapper.queryByName(monitorScene.getMonitorSceneName());
+        if(monitorScene1!=null){
+            return -1;
+        }
+        this.monitorSceneMapper.insert(monitorScene);
+        return monitorScene.getId();
     }
 
     /**

+ 1 - 1
smartcity-facilities/src/main/resources/mapper/CameraMapper.xml

@@ -136,7 +136,7 @@
         channel_no, channel_name, ipc_serial, date_create, date_update, create_by, update_by, status, site_id,
         monitor_point_id, monitor_scene_id, pic_url, camera_status, video_status)
         values
-        <foreach collection="cameraDTO.cameras" item="item" index="index" separator=",">
+        <foreach collection="cameraDTO.saveCameras" item="item" index="index" separator=",">
             (
             #{item.id}, #{item.deviceSerial}, #{item.appKey}, #{item.appSecret}, #{item.manufacturer}, #{item.platform},
             #{item.verificationCode}, #{item.channelNo}, #{item.channelName}, #{item.ipcSerial}, #{item.dateCreate},

+ 158 - 0
smartcity-facilities/src/main/resources/mapper/ManufacturerMapper.xml

@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zcxk.facilities.dao.ManufacturerMapper">
+    <!-- 结果集 -->
+    <resultMap type="com.zcxk.facilities.entity.Manufacturer" id="ManufacturerMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="type" column="type" jdbcType="INTEGER"/>
+        <result property="status" column="status" jdbcType="INTEGER"/>
+        <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
+        <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
+        <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
+        <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <!-- 基本字段 -->
+    <sql id="Base_Column_List">
+        id, name, type, status, create_date, create_by, update_date, update_by    </sql>
+
+    <!-- 查询单个 -->
+    <select id="selectById" resultMap="ManufacturerMap">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_manufacturer
+        where id = #{id}
+    </select>
+
+
+    <!-- 查询全部 -->
+    <select id="selectAll" resultMap="ManufacturerMap">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_manufacturer
+    </select>
+
+    <!--通过实体作为筛选条件查询-->
+    <select id="selectList" resultMap="ManufacturerMap">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_manufacturer
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="name != null and name != ''">
+                and name = #{name}
+            </if>
+            <if test="type != null">
+                and type = #{type}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="createDate != null">
+                and create_date = #{createDate}
+            </if>
+            <if test="createBy != null and createBy != ''">
+                and create_by = #{createBy}
+            </if>
+            <if test="updateDate != null">
+                and update_date = #{updateDate}
+            </if>
+            <if test="updateBy != null and updateBy != ''">
+                and update_by = #{updateBy}
+            </if>
+        </where>
+    </select>
+
+    <!-- 新增所有列 -->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into sc_manufacturer(id, name, type, status, create_date, create_by, update_date, update_by)
+        values (#{id}, #{name}, #{type}, #{status}, #{createDate}, #{createBy}, #{updateDate}, #{updateBy})
+    </insert>
+
+    <!-- 批量新增 -->
+    <insert id="batchInsert">
+        insert into sc_manufacturer(id, name, type, status, create_date, create_by, update_date, update_by)
+        values
+        <foreach collection="manufacturers" item="item" index="index" separator=",">
+            (
+            #{item.id}, #{item.name}, #{item.type}, #{item.status}, #{item.createDate}, #{item.createBy},
+            #{item.updateDate}, #{item.updateBy} )
+        </foreach>
+    </insert>
+
+    <!-- 通过主键修改数据 -->
+    <update id="update">
+        update sc_manufacturer
+        <set>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="type != null">
+                type = #{type},
+            </if>
+            <if test="status != null">
+                status = #{status},
+            </if>
+            <if test="createDate != null">
+                create_date = #{createDate},
+            </if>
+            <if test="createBy != null and createBy != ''">
+                create_by = #{createBy},
+            </if>
+            <if test="updateDate != null">
+                update_date = #{updateDate},
+            </if>
+            <if test="updateBy != null and updateBy != ''">
+                update_by = #{updateBy},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete
+        from sc_manufacturer
+        where id = #{id}
+    </delete>
+
+    <!-- 总数 -->
+    <select id="count" resultType="int">
+        select count(*)
+        from sc_manufacturer
+    </select>
+    <select id="selectPage" resultMap="ManufacturerMap">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_manufacturer
+        <where>
+            <if test="manufacturer.id != null">
+                and id = #{manufacturer.id}
+            </if>
+            <if test="manufacturer.name != null and manufacturer.name != ''">
+                and name = #{manufacturer.name}
+            </if>
+            <if test="manufacturer.type != null">
+                and type = #{manufacturer.type}
+            </if>
+            <if test="manufacturer.status != null">
+                and status = #{manufacturer.status}
+            </if>
+            <if test="manufacturer.createDate != null">
+                and create_date = #{manufacturer.createDate}
+            </if>
+            <if test="manufacturer.createBy != null and manufacturer.createBy != ''">
+                and create_by = #{manufacturer.createBy}
+            </if>
+            <if test="manufacturer.updateDate != null">
+                and update_date = #{manufacturer.updateDate}
+            </if>
+            <if test="manufacturer.updateBy != null and manufacturer.updateBy != ''">
+                and update_by = #{manufacturer.updateBy}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 12 - 1
smartcity-facilities/src/main/resources/mapper/MonitorPointMapper.xml

@@ -172,7 +172,18 @@
         <where>
             a.status=1 and b.status=1
             <if test="siteId != null">
-                and site_id = #{siteId}
+                and b.site_id = #{siteId}
+            </if>
+        </where>
+    </select>
+    <select id="queryByName" resultType="com.zcxk.facilities.entity.MonitorPoint">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_monitor_point
+        <where>
+        status=1
+            <if test="monitorPointName != null and monitorPointName != ''">
+                and monitor_point_name = #{monitorPointName}
             </if>
         </where>
     </select>

+ 13 - 0
smartcity-facilities/src/main/resources/mapper/MonitorSceneMapper.xml

@@ -136,6 +136,19 @@
         select count(*)
         from sc_monitor_scene
     </select>
+    <select id="queryByName" resultType="com.zcxk.facilities.entity.MonitorScene">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_monitor_scene
+        <where>
+            status=1
+            <if test="monitorSceneName != null and monitorSceneName != ''">
+                and monitor_scene_name = #{monitorSceneName}
+            </if>
+
+        </where>
+
+    </select>
     <update id="deleteAllPoints">
         update sc_monitor_point set status=0 where monitor_scene_id=#{id}
     </update>