Browse Source

"视频点位;视频类型"

yangjunfeng 11 months ago
parent
commit
9f764e64f1

+ 128 - 0
hnls-gis/src/main/java/com/tofly/xrtygis/controller/TfCameraTypeController.java

@@ -0,0 +1,128 @@
+/*
+ * Author: wangjian
+ * 生成controller
+ */
+package com.tofly.xrtygis.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.common.log.annotation.ToFlyAppLog;
+import com.tofly.xrtygis.entity.TfCameraType;
+import com.tofly.xrtygis.service.TfCameraTypeService;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import org.springframework.web.bind.annotation.ModelAttribute;
+
+import java.util.Arrays;
+/**
+ * 摄像头所属类型
+ *
+ * @author admin
+ * @date Thu Jun 01 00:00:00 CST 2023
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/tfcameratype")
+@Api(tags="摄像头所属类型接口")
+public class TfCameraTypeController {
+
+    private final  TfCameraTypeService tfCameraTypeService;
+
+    /**
+    * 分页查询
+    * @param page 分页对象
+    * @param tfCameraType 摄像头所属类型
+    * @return
+    */
+    @GetMapping("/page" )
+    @ApiOperation(value = "分页查询")
+    public ResultRespone getTfCameraTypePage(Page page, @ModelAttribute TfCameraType tfCameraType) {
+      return ResultRespone.success(tfCameraTypeService.page(page, Wrappers.query(tfCameraType)));
+    }
+
+    /**
+     * @return
+     */
+    @GetMapping("/tree" )
+    @ApiOperation(value = "获取树类型形结构,id为空查询所有,id不为空,查询指定id下所有数据")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "ID", required = false, dataType = "String")
+    })
+    public ResultRespone getTfCameraTypeList(String id) {
+        return ResultRespone.success(tfCameraTypeService.getTfCameraTypeList(id));
+    }
+
+    /**
+     * 通过id查询摄像头所属类型
+     * @param id id
+     * @return ResultRespone
+     */
+    @GetMapping("/{id}" )
+    @ApiOperation(value = "通过ID查询")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
+    })
+    public ResultRespone getById(@PathVariable("id" ) String id) {
+      return ResultRespone.success(tfCameraTypeService.getById(id));
+    }
+
+    /**
+     * 新增摄像头所属类型
+     * @param tfCameraType 摄像头所属类型
+     * @return ResultRespone
+     */
+    @ToFlyAppLog(title="新增摄像头所属类型" )
+    @ApiOperation(value = "新增摄像头所属类型")
+    @PostMapping
+    public ResultRespone save(@RequestBody TfCameraType tfCameraType) {
+      return ResultRespone.success(tfCameraTypeService.save(tfCameraType));
+    }
+
+    /**
+     * 修改摄像头所属类型
+     * @param tfCameraType 摄像头所属类型
+     * @return ResultRespone
+     */
+    @ToFlyAppLog(title="修改摄像头所属类型" )
+    @ApiOperation(value = "修改摄像头所属类型")
+    @PutMapping
+    public ResultRespone updateById(@RequestBody TfCameraType tfCameraType) {
+      return ResultRespone.success(tfCameraTypeService.updateById(tfCameraType));
+    }
+
+    /**
+     * 通过id删除摄像头所属类型
+     * @param id id
+     * @return ResultRespone
+     */
+    @ToFlyAppLog(title="通过id删除摄像头所属类型" )
+    @ApiOperation(value = "通过ID删除摄像头所属类型")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
+    })
+    @DeleteMapping("/{id}" )
+    public ResultRespone removeById(@PathVariable String id) {
+      return ResultRespone.success(tfCameraTypeService.deleteByIds(id));
+    }
+
+    /**
+     * 通过id批量删除摄像头所属类型
+     * @param ids id
+     * @return ResultRespone
+     */
+    @ToFlyAppLog(title="通过id批量删除摄像头所属类型" )
+    @ApiOperation(value = "通过ID批量删除摄像头所属类型")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ids", value = "批量删除,多个id以逗号隔开", required = true, dataType = "String")
+    })
+    @DeleteMapping("/deleteByIds" )
+    public ResultRespone removeByIds(String ids) {
+        return ResultRespone.success(tfCameraTypeService.deleteByIds(ids));
+
+    }
+}

+ 27 - 1
hnls-gis/src/main/java/com/tofly/xrtygis/entity/TfCameraManage.java

@@ -141,5 +141,31 @@ public class TfCameraManage extends Model<TfCameraManage> {
             @ApiModelProperty(value = "所属权属状态转义(1水厂,2管网,0未定义)")
             @TableField(exist = false)
                 private String belongStatusName;
-            
+    /**
+     * 类型id
+     */
+    @ApiModelProperty(value = "所属类型id,关联类型表")
+
+    private String typeId;
+
+    /**
+     * 类型名称(1水厂,2管网,0未定义)
+     */
+    @ApiModelProperty(value = "所属类型名称")
+    @TableField(exist = false)
+    private String typeName;
+
+    /**
+     * 类型父Id
+     */
+    @ApiModelProperty(value = "类型父Id")
+    @TableField(exist = false)
+    private String typeParentId;
+
+    /**
+     * 类型父名称
+     */
+    @ApiModelProperty(value = "父类型名称")
+    @TableField(exist = false)
+    private String typeParentName;
 }

+ 94 - 0
hnls-gis/src/main/java/com/tofly/xrtygis/entity/TfCameraType.java

@@ -0,0 +1,94 @@
+/*
+ * Author: wangjian
+ * 生成entity
+ */
+package com.tofly.xrtygis.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+
+/**
+ * 摄像头所属类型
+ *
+ * @author admin
+ * @date Thu Jun 01 00:00:00 CST 2023
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName(value = "TF_CAMERA_TYPE", resultMap = "tfCameraTypeMap")
+@ApiModel
+public class TfCameraType extends Model<TfCameraType> {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "ID", type = IdType.ASSIGN_UUID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+    /**
+     * 类型名称
+     */
+    @ApiModelProperty(value = "类型名称")
+    @NotNull(message = "类型名称不能为空")
+    private String name;
+    /**
+     * 父Id
+     */
+    @ApiModelProperty(value = "父Id,没有就不传")
+    private String parentId;
+    /**
+     * 显示排序
+     */
+    @ApiModelProperty(value = "显示排序")
+    private BigDecimal showNum;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    @TableField(value = "CREATE_USER", fill = FieldFill.INSERT)
+    private Long createUser;
+    @ApiModelProperty(hidden = true)
+    @TableField(exist = false)
+    private String createUserName;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty(value = "修改时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @TableField(value = "UPDATE_TIME", fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+    /**
+     * 更新人员
+     */
+    @ApiModelProperty(value = "更新人员")
+    @TableField(value = "UPDATE_USER", fill = FieldFill.INSERT_UPDATE)
+    private Long updateUser;
+    @ApiModelProperty(hidden = true)
+    @TableField(exist = false)
+    private String updateUserName;
+
+}

+ 14 - 0
hnls-gis/src/main/java/com/tofly/xrtygis/entity/vo/TfCameraTypeVo.java

@@ -0,0 +1,14 @@
+package com.tofly.xrtygis.entity.vo;
+
+import com.tofly.xrtygis.entity.TfCameraType;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TfCameraTypeVo  extends TfCameraType {
+
+    @ApiModelProperty(value = "子集")
+    private List<TfCameraTypeVo> children;
+}

+ 23 - 0
hnls-gis/src/main/java/com/tofly/xrtygis/mapper/TfCameraTypeMapper.java

@@ -0,0 +1,23 @@
+/*
+ * Author: wangjian
+ * 生成mapper
+ */
+package com.tofly.xrtygis.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.tofly.xrtygis.entity.TfCameraType;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+
+import java.util.List;
+/**
+ * 摄像头所属类型
+ *
+ * @author admin
+ * @date Thu Jun 01 00:00:00 CST 2023
+ */
+public interface TfCameraTypeMapper extends BaseMapper<TfCameraType> {
+
+   List<String> getTypeList(@Param("typeIds")String typeIds);
+ }

+ 25 - 0
hnls-gis/src/main/java/com/tofly/xrtygis/service/TfCameraTypeService.java

@@ -0,0 +1,25 @@
+/*
+ * Author: wangjian
+ * 生成Service
+ */
+package com.tofly.xrtygis.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.tofly.xrtygis.entity.TfCameraType;
+import com.tofly.xrtygis.entity.vo.TfCameraTypeVo;
+
+import java.util.List;
+
+/**
+ * 摄像头所属类型
+ *
+ * @author admin
+ * @date Thu Jun 01 00:00:00 CST 2023
+ */
+public interface TfCameraTypeService extends IService<TfCameraType> {
+
+    List<TfCameraTypeVo> getTfCameraTypeList(String id);
+
+    boolean deleteByIds(String ids);
+}

+ 100 - 0
hnls-gis/src/main/java/com/tofly/xrtygis/service/impl/TfCameraTypeServiceImpl.java

@@ -0,0 +1,100 @@
+/*
+ * Author: wangjian
+ * 生成ServiceImpl
+ */
+package com.tofly.xrtygis.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tofly.common.core.util.StringUtil;
+import com.tofly.common.oauth.util.SecurityUtils;
+import com.tofly.pojo.CustomCode;
+import com.tofly.xrtygis.entity.TfCameraManage;
+import com.tofly.xrtygis.entity.TfCameraType;
+import com.tofly.xrtygis.entity.vo.TfCameraTypeVo;
+import com.tofly.xrtygis.service.TfCameraManageService;
+import com.tofly.xrtygis.service.TfCameraTypeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.tofly.xrtygis.mapper.TfCameraTypeMapper;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 摄像头所属类型
+ *
+ * @author admin
+ * @date Thu Jun 01 00:00:00 CST 2023
+ */
+@Service("tfCameraTypeService")
+public class TfCameraTypeServiceImpl extends ServiceImpl<TfCameraTypeMapper, TfCameraType> implements TfCameraTypeService {
+
+    @Autowired
+    TfCameraManageService tfCameraManageService;
+
+    @Override
+    public List<TfCameraTypeVo> getTfCameraTypeList(String id) {
+       List<TfCameraType> codeList = this.list(Wrappers.<TfCameraType>lambdaQuery()
+                .orderByAsc(TfCameraType::getShowNum));
+
+        List<TfCameraTypeVo> customCodes = JSONObject.parseArray(JSON.toJSONString(codeList),TfCameraTypeVo.class);
+
+        List<TfCameraTypeVo> customCodes1;
+        if(StringUtil.isNotEmpty(id)){
+            customCodes1 = customCodes.stream().filter(m -> m.getId().equals(id))
+                    .map((m) -> {
+
+                                m.setChildren(getChildrens(m, customCodes));
+                                return m;
+                            }
+                    ).collect(Collectors.toList());
+
+        }else{
+            customCodes1 = customCodes.stream().filter(m -> m.getParentId() == null)
+                    .map((m) -> {
+
+                                m.setChildren(getChildrens(m, customCodes));
+                                return m;
+                            }
+                    ).collect(Collectors.toList());
+        }
+        return customCodes1;
+
+    }
+
+    private List<TfCameraTypeVo> getChildrens(TfCameraTypeVo parent, List<TfCameraTypeVo> menuDatas) {
+        List<TfCameraTypeVo> childList = menuDatas.stream().filter(m -> {
+            return Objects.equals(m.getParentId(), parent.getId());
+        }).map((m) -> {
+
+            m.setChildren(getChildrens(m, menuDatas));
+            return m;
+        }).collect(Collectors.toList());
+        return childList;
+    }
+
+    @Override
+    public boolean deleteByIds(String ids) {
+        List<String> list = Arrays.asList(ids.split(","));
+
+        Integer  count_check =0;
+        count_check=tfCameraManageService.count(Wrappers.<TfCameraManage>lambdaQuery()
+                .in(TfCameraManage::getTypeId,list));
+        if (count_check > 0) {
+            throw new RuntimeException("摄像头管理里面有对应的类别数据,请先修改对应的类别,再执行删除操作");
+        }
+        count_check=this.count(Wrappers.<TfCameraType>lambdaQuery()
+        .isNull(TfCameraType::getParentId)
+         .in(TfCameraType::getParentId,list));
+        if (count_check > 0) {
+            throw new RuntimeException("选择的数据存在子类别,请先删除子类别,再删除该类别");
+        }
+        return this.removeByIds(list);
+    }
+}

+ 25 - 0
hnls-gis/src/main/resources/mapper/common/TfCameraManageMapper.xml

@@ -21,6 +21,13 @@
                       <result property="longitude" column="LONGITUDE"/>
                       <result property="latitude" column="LATITUDE"/>
                       <result property="describe" column="DESCRIBE"/>
+                      <result property="typeId" column="TYPE_ID"/>
+                      <association property="typeName" column="TYPE_ID"
+                                   select="getTypeName"/>
+                      <association property="typeParentId" column="TYPE_ID"
+                                   select="getTypeParentId"/>
+                      <association property="typeParentName" column="TYPE_ID"
+                                   select="getTypeParentName"/>
                       <association property="createUserName" column="CREATE_USER"
                                    select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"></association>
                       <association property="waterName" column="WATER_ID"
@@ -34,4 +41,22 @@
         SELECT decode(#{belongStatus},'0','未定义','1','水厂','2','管网') as belongStatusName FROM dual
     </select>
 
+    <select id="getTypeName" resultType="string">
+        select name
+        from TF_CAMERA_TYPE
+        where id = #{typeId}
+    </select>
+    <select id="getTypeParentId" resultType="string">
+        select parent_id
+        from TF_CAMERA_TYPE
+        where id = #{typeId}
+    </select>
+
+    <select id="getTypeParentName" resultType="string">
+        select name from tf_camera_type where id in(
+            select parent_id from tf_camera_type t
+            where t.id=#{typeId}
+        )
+    </select>
+
 </mapper>

+ 33 - 0
hnls-gis/src/main/resources/mapper/common/TfCameraTypeMapper.xml

@@ -0,0 +1,33 @@
+<?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.tofly.xrtygis.mapper.TfCameraTypeMapper">
+
+    <resultMap id="tfCameraTypeMap" type="com.tofly.xrtygis.entity.TfCameraType">
+        <id property="id" column="ID"/>
+        <result property="name" column="NAME"/>
+        <result property="parentId" column="PARENT_ID"/>
+        <result property="showNum" column="SHOW_NUM"/>
+        <result property="createUser" column="CREATE_USER"/>
+        <result property="createTime" column="CREATE_TIME"/>
+        <result property="updateTime" column="UPDATE_TIME"/>
+        <result property="updateUser" column="UPDATE_USER"/>
+        <association property="createUserName" column="CREATE_USER"
+                     select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"/>
+        <association property="updateUserName" column="UPDATE_USER"
+                     select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"/>
+    </resultMap>
+
+    <select id="getTypeList" resultType="string">
+
+        SELECT id
+        FROM tf_camera_type t
+        START WITH t.id in
+        <foreach item="nodeCodestr" collection="typeIds.split(',')" open="(" separator="," close=")">
+            #{nodeCodestr}
+        </foreach>
+
+        CONNECT BY PRIOR t.ID = t.parent_id
+    </select>
+
+</mapper>