Переглянути джерело

Merge remote-tracking branch 'origin/V1.0.11' into V1.0.11

jingyuanchao 11 місяців тому
батько
коміт
697de6c229

+ 9 - 0
project_data/sql/1.0.11/soc.sql

@@ -186,6 +186,8 @@ CREATE TABLE `iot_device_diagnose_mission` (
   `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
   PRIMARY KEY (`mission_id`) USING BTREE
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断任务表';
+-- 诊断任务默认
+INSERT INTO `iot_device_diagnose_mission` VALUES ('5ed19826-dd47-421e-a632-b00ba9271c45', '默认', '00:00:00', '23:59:59', '1', '0.1','2024-11-18 17:03:54',null);
 
 drop table if exists `iot_device_diagnose_mission_ch`;
 CREATE TABLE `iot_device_diagnose_mission_ch` (
@@ -216,8 +218,11 @@ CREATE TABLE `iot_device_diagnose_threshold` (
   `type` bigint DEFAULT NULL COMMENT '是否默认标识,1为默认,0为其他',
   `validityBeginTime` time DEFAULT NULL COMMENT '有效开始时间',
   `validityEndTime` time DEFAULT NULL COMMENT '有效结束时间',
+  `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
   PRIMARY KEY (`threshold_code`) USING BTREE
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断阈值表';
+-- 诊断阈值默认
+INSERT INTO `iot_device_diagnose_threshold` VALUES ('0cdd75ea0d73056dbd6727b96339f2f6', '默认', '@value==255', '@value>=250', '@value>=150', '@value>=7', '@value>=255', '@value>=225', '@value>=140', '@value>=253', '@value<=0',  '2024-11-18 17:03:54', '0', '1', '00:00:00', '23:59:59',null);
 
 drop table if exists `iot_device_diagnose_threshold_ch`;
 CREATE TABLE `iot_device_diagnose_threshold_ch` (
@@ -233,3 +238,7 @@ CREATE TABLE `iot_device_diagnose_threshold_ch` (
 delete from iot_server_product where id in ('0a3fa02d-c677-4f8a-a053-4e30e592df7e','20fa2a1a-a069-4975-8d64-091a39539e02');
 INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`, `models`) VALUES ('0a3fa02d-c677-4f8a-a053-4e30e592df7e', 'TALK_HOST', '对讲主机', 1, '[\r\n  \"Host_Talk\"\r\n]', '[\r\n  \"Normal\"\r\n]');
 INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`, `models`) VALUES ('20fa2a1a-a069-4975-8d64-091a39539e02', 'DOOR_HOST', '门禁主机', 1, '[\r\n  \"Host_Door\"\r\n]', '[\r\n  \"Normal\"\r\n]');
+
+-- 摄像机诊断菜单
+INSERT INTO `sys_menu` VALUES (01747915341556742146, '视频诊断任务', 1747911340288892930, 3, 'diagnoseMission', 'iot/diagnoseMission', NULL, 1, 0, 'C', '0', '0', 'iot:diagnoseMission', '1', 'client', NULL, '超级管理员', '2024-11-18 17:22:07', '超级管理员', '2024-11-18 17:22:07', '');
+INSERT INTO `sys_menu` VALUES (01761830909641408513, '视频诊断阈值', 1747911340288892930, 2, 'diagnoseThreshold', 'iot/diagnoseThreshold', NULL, 1, 0, 'C', '0', '0', 'iot:diagnoseThreshold', '1', 'client', NULL, '超级管理员', '2024-11-18 09:37:19', '超级管理员', '2024-11-18 09:37:19', '');

+ 34 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/CameraDiagnoseThresholdController.java

@@ -0,0 +1,34 @@
+package com.xunmei.iot.controller;
+
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
+import com.xunmei.iot.service.DiagnoseThresholdService;
+import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/diagnoseThreshold")
+public class CameraDiagnoseThresholdController {
+
+    @Resource
+    private DiagnoseThresholdService diagnoseThresholdService;
+
+    @ApiOperation("诊断阈值绑定列表")
+    @PostMapping({"/list"})
+    public TableDataInfo<DiagnoseThresholdPageVo> webPage(@RequestBody final DiagnoseThresholdPageDto request) {
+        TableDataInfo<DiagnoseThresholdPageVo> page = diagnoseThresholdService.selectSensorDataPage(request);
+        return page;
+    }
+
+    @ApiOperation("获取告警类型下拉列表数据")
+    @GetMapping({"/thresholdTypeList"})
+    List<AlarmTypeSelectedVO> thresholdTypeList() {
+
+        return diagnoseThresholdService.thresholdTypeList();
+    }
+}

+ 25 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/cameraDiagnose/DiagnoseThresholdPageDto.java

@@ -0,0 +1,25 @@
+package com.xunmei.iot.dto.cameraDiagnose;
+
+import com.xunmei.common.core.web.domain.PageRequest;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/2/26 14:32
+ */
+@Data
+public class DiagnoseThresholdPageDto extends PageRequest {
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+
+    @ApiModelProperty(value = "绑定状态:0:未绑定,1:已绑定")
+    private Integer state;
+
+    @ApiModelProperty(value = "阈值code")
+    private String thresholdCode;
+
+}

+ 16 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/DiagnoseThresholdChMapper.java

@@ -0,0 +1,16 @@
+package com.xunmei.iot.mapper;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
+import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface DiagnoseThresholdChMapper {
+    Page<DiagnoseThresholdPageVo> selectPageData(Page<DiagnoseThresholdPageVo> pageRequest, @Param("request") DiagnoseThresholdPageDto request);
+    List<IotDeviceDiagnoseThreshold> selectAllDiagnoseThreshold();
+}

+ 15 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/DiagnoseThresholdService.java

@@ -0,0 +1,15 @@
+package com.xunmei.iot.service;
+
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
+import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
+
+import java.util.List;
+
+public interface DiagnoseThresholdService {
+
+    TableDataInfo<DiagnoseThresholdPageVo> selectSensorDataPage(DiagnoseThresholdPageDto request);
+
+    List<AlarmTypeSelectedVO> thresholdTypeList();
+}

+ 109 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/DiagnoseThresholdServiceImpl.java

@@ -0,0 +1,109 @@
+package com.xunmei.iot.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
+import com.xunmei.common.core.constant.CacheConstants;
+import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
+import com.xunmei.common.core.enums.OrgTypeEnum;
+import com.xunmei.common.core.utils.StringUtils;
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.redis.utils.RedisUtils;
+import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
+import com.xunmei.iot.mapper.DiagnoseThresholdChMapper;
+import com.xunmei.iot.service.DiagnoseThresholdService;
+import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
+import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.vo.SysOrgVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class DiagnoseThresholdServiceImpl  implements DiagnoseThresholdService {
+    @Resource
+    private RemoteOrgService orgService;
+
+    @Autowired
+    private DiagnoseThresholdChMapper diagnoseThresholdChMapper;
+
+    @Override
+    public TableDataInfo<DiagnoseThresholdPageVo> selectSensorDataPage(DiagnoseThresholdPageDto request) {
+        final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
+        if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
+            request.setOrgPath(sysOrg.getPath());
+            request.setOrgId(null);
+        }
+
+        List<IotDeviceDiagnoseThreshold> thresholds = diagnoseThresholdChMapper.selectAllDiagnoseThreshold();
+
+        Page<DiagnoseThresholdPageVo> page = diagnoseThresholdChMapper.selectPageData(request.getPageRequest(), request);
+        final List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
+
+        for (DiagnoseThresholdPageVo bean : page.getRecords()) {
+            String thresholdCodes = bean.getThresholdCodes();
+            final List<Long> collect = Arrays.stream(bean.getOrgPath().split("-")).map(Long::parseLong).collect(Collectors.toList());
+            //地区名称
+            cacheList.stream().filter(org -> collect.contains(org.getId()) && OrgTypeEnum.DIQU_HANG_SHE.getCode().equals(org.getType()))
+                              .findFirst().ifPresent(org -> bean.setFirstOrgName(org.getShortName()));
+            //行社名称
+            cacheList.stream().filter(org -> collect.contains(org.getId()) && OrgTypeEnum.HANG_SHE.getCode().equals(org.getType()))
+                              .findFirst().ifPresent(org -> bean.setSecondOrgName(org.getShortName()));
+
+            StringBuffer buffer = new StringBuffer();
+            if(StringUtils.isNotEmpty(thresholdCodes)){
+                String[] codes = thresholdCodes.split(",");
+                boolean isMatch = false;
+                for(String code:codes){
+                    for(IotDeviceDiagnoseThreshold threshold:thresholds){
+                        if(threshold.getThresholdCode().equals(code)){
+                            buffer.append(threshold.getThresholdName()).append("【")
+                                    .append(threshold.getValiditybegintime()).append("--").append(threshold.getValidityendtime())
+                                    .append("】").append(",");
+                            isMatch = true;
+                        }
+                    }
+                }
+                if(isMatch){
+                    bean.setThresholdName(buffer.substring(0,buffer.length()-1));
+                }else{
+                    bean.setThresholdName("--");
+                }
+            }else{
+                bean.setThresholdName("--");
+            }
+
+        }
+        return TableDataInfo.build(page);
+    }
+
+
+    @Override
+    public List<AlarmTypeSelectedVO> thresholdTypeList() {
+        List<AlarmTypeSelectedVO> list = Lists.newArrayList();
+        AlarmTypeSelectedVO bean;
+        List<IotDeviceDiagnoseThreshold> thresholds = diagnoseThresholdChMapper.selectAllDiagnoseThreshold();
+
+        StringBuffer buffer;
+        for (IotDeviceDiagnoseThreshold threshold : thresholds) {
+            bean = new AlarmTypeSelectedVO();
+
+            buffer = new StringBuffer();
+            buffer.append(threshold.getThresholdName()).append("【")
+                    .append(threshold.getValiditybegintime()).append("--").append(threshold.getValidityendtime())
+                    .append("】");
+
+            bean.setValue(threshold.getThresholdCode());
+            bean.setLabel(buffer.toString());
+            list.add(bean);
+        }
+
+        return list;
+    }
+}

+ 37 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/DiagnoseThresholdPageVo.java

@@ -0,0 +1,37 @@
+package com.xunmei.iot.vo.sensor;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class DiagnoseThresholdPageVo {
+    @ApiModelProperty("设备id")
+    private Long id;
+
+    @ApiModelProperty("设备名称")
+    private String deviceName;
+
+    @ApiModelProperty("所属主机")
+    private String hostName;
+
+    @ApiModelProperty("所属机构")
+    private String orgName;
+
+    @ApiModelProperty("诊断阈值")
+    private String thresholdName;
+
+    @ApiModelProperty("地区")
+    private String firstOrgName;
+
+    @ApiModelProperty("行社名称")
+    private String secondOrgName;
+
+    @JsonIgnore
+    @ApiModelProperty("机构路径")
+    private String orgPath;
+
+    @JsonIgnore
+    @ApiModelProperty("机构路径")
+    private String thresholdCodes;
+}

+ 50 - 0
soc-modules/soc-modules-iot/src/main/resources/mapper/DiagnoseThresholdChMapper.xml

@@ -0,0 +1,50 @@
+<?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.xunmei.iot.mapper.DiagnoseThresholdChMapper">
+
+    <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo">
+        select c.* from
+        (
+            select s.id,s.org_id, s.org_name,s.org_path, s.device_name, dvs.device_name as host_name,
+            (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
+            and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
+            from iot_device_info s
+            inner join iot_device_info dvs on dvs.iot_token = s.iot_token
+            and dvs.device_product = s.device_product and dvs.device_code = s.host_code
+            and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
+            where s.deleted=0 and s.enable=0 and s.device_type = 2
+            <if test="request.orgId!= null">
+                and s.org_id=#{request.orgId}
+            </if>
+            <if test="request.orgPath!= null">
+                and s.org_path like CONCAT(#{request.orgPath}, '%')
+            </if>
+            <if test="request.deviceName != null and request.deviceName!= ''">
+                and s.device_name like CONCAT('%',#{request.deviceName},'%')
+            </if>
+            order by s.host_code ,cast(s.device_code as signed)
+        ) c where 1=1
+        <choose>
+            <when test=" request.state == null">
+            </when>
+            <when test=" request.state == 0">
+                and c.threshold_codes is null
+            </when>
+            <otherwise>
+                and c.threshold_codes is not null
+            </otherwise>
+        </choose>
+        <choose>
+            <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
+                and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+
+    </select>
+
+    <select id="selectAllDiagnoseThreshold" resultType="com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold">
+        select * from iot_device_diagnose_threshold
+    </select>
+</mapper>