Browse Source

相机导入修改和筛选

gao.qiang 2 months ago
parent
commit
dd295e393d

+ 13 - 0
business-service/src/main/java/com/ozs/service/entity/BaseCameraManagement.java

@@ -1,6 +1,7 @@
 package com.ozs.service.entity;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
 
@@ -218,6 +219,18 @@ public class BaseCameraManagement extends BaseEntity implements Serializable ,Co
     @TableField(exist = false)
     private Integer isDisable;
 
+    /**
+     * 最后心跳时间
+     */
+    @TableField(exist = false)
+    private LocalDateTime heartTime;
+
+    /**
+     * 剩余电量
+     */
+    @TableField(exist = false)
+    private Integer electricity;
+
     @Override
     public int compareTo(BaseCameraManagement o) {
         int i =o.getRailwayName().compareTo(o.railwayName);

+ 2 - 0
business-service/src/main/java/com/ozs/service/entity/vo/BaseCameraManagementVo.java

@@ -36,6 +36,8 @@ public class BaseCameraManagementVo extends PageVo implements Serializable {
      */
     private String railwayCode;
 
+    private Integer railwayType;
+
     /**
      * 监控范围开始里程位置
      */

+ 4 - 1
business-service/src/main/java/com/ozs/service/entity/vo/Codec.java

@@ -2,10 +2,13 @@ package com.ozs.service.entity.vo;
 
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * @author Administrator
  */
 @Data
 public class Codec {
-    private Venc0 venc0;
+    private List<Venc> venc;
+    private Day2night day2night;
 }

+ 14 - 0
business-service/src/main/java/com/ozs/service/entity/vo/Day2night.java

@@ -0,0 +1,14 @@
+package com.ozs.service.entity.vo;
+
+import lombok.Data;
+
+@Data
+public class Day2night {
+    private  Integer mode;
+    private  Integer n2i_thr=16000;
+    private  Integer i2n_thr=250;
+    private  Integer light1=0;
+    private  Integer light2=0;
+    private  Integer btime=21600;
+    private  Integer etime=64800;
+}

+ 20 - 0
business-service/src/main/java/com/ozs/service/entity/vo/Venc.java

@@ -0,0 +1,20 @@
+package com.ozs.service.entity.vo;
+
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class Venc {
+    private Integer index = 0;
+    private Integer type = 0;
+    private Integer width = 1920;
+    private Integer height = 1080;
+    private Integer gop = 1;
+    private Integer bitrate = 4096;
+    private Integer profile = 1;
+    private Integer rcmode = 1;
+    private Integer qfactor = 0;
+    private Double fps;
+}

+ 0 - 11
business-service/src/main/java/com/ozs/service/entity/vo/Venc0.java

@@ -1,11 +0,0 @@
-package com.ozs.service.entity.vo;
-
-import lombok.Data;
-
-/**
- * @author Administrator
- */
-@Data
-public class Venc0 {
-    private Double fps;
-}

+ 11 - 35
business-service/src/main/java/com/ozs/service/service/impl/BaseCameraManagementServiceImpl.java

@@ -80,6 +80,9 @@ public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManag
             try {
                 BaseCameraManagement accountManagement = new BaseCameraManagement();
                 BeanUtils.copyProperties(cameraManagementVos, accountManagement);
+                accountManagement.setBeginMile(AppendUtils.stringSplit(accountManagement.getBeginMiles()));
+                accountManagement.setEndMile(AppendUtils.stringSplit(accountManagement.getEndMiles()));
+                accountManagement.setInstallMile(AppendUtils.stringSplit(accountManagement.getInstallMiles()));
                 // 判断相机编码是否存在
                 LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
                 if (!ObjectUtils.isEmpty(accountManagement.getCameraCode())) {
@@ -100,42 +103,15 @@ public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManag
                         }
                         BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
                         if (!ObjectUtils.isEmpty(baseRailwayManagement)) {
-                            if (!accountManagement.getInstallMiles().matches(PATTERN)) {
-                                failureNum++;
-                                failureMsg.append(failureNum + "、相机编码为: " + accountManagement.getCameraCode() + "的数据,安装里程位置填写格式不正确,请填写数字");
-                            } else {
-                                BigDecimal install = new BigDecimal(accountManagement.getInstallMiles());
                                 accountManagement.setRailwayCode(baseRailwayManagement.getRailwayCode());
-                                accountManagement.setInstallMile( install.multiply(BigDecimal.valueOf(1000)).intValue());
-                                if (!ObjectUtils.isEmpty(accountManagement.getBeginMiles()) && !ObjectUtils.isEmpty(accountManagement.getEndMiles())) {
-                                    BigDecimal end = new BigDecimal(accountManagement.getEndMiles());
-                                    BigDecimal begin =new BigDecimal(accountManagement.getBeginMiles());
-                                    accountManagement.setEndMile(end.multiply(BigDecimal.valueOf(1000)).intValue());
-                                    accountManagement.setBeginMile(begin.multiply(BigDecimal.valueOf(1000)).intValue());
-                                    if (!accountManagement.getBeginMiles().matches(PATTERN) || !accountManagement.getEndMiles().matches(PATTERN)) {
-                                        failureNum++;
-                                        failureMsg.append(failureNum + "、相机编码为: " + accountManagement.getCameraCode() + "的数据,监控范围里程位置填写格式不正确,请填写数字");
-                                    } else {
-                                            baseCameraManagementMapper.insert(accountManagement);
-                                            BaseDeviceDynamicManagement baseDeviceDynamicManagement = new BaseDeviceDynamicManagement();
-                                            baseDeviceDynamicManagement.setCameraCode(accountManagement.getCameraCode());
-                                            baseDeviceDynamicManagement.setUpdateBy(userId);
-                                            baseDeviceDynamicManagement.setCreateBy(userId);
-                                            baseDeviceDynamicManagementMapper.insert(baseDeviceDynamicManagement);
-                                            successNum++;
-                                            successMsg.append(successNum + "、相机编码 " + accountManagement.getCameraCode() + " 导入成功");
-                                    }
-                                } else {
-                                    baseCameraManagementMapper.insert(accountManagement);
-                                    BaseDeviceDynamicManagement baseDeviceDynamicManagement = new BaseDeviceDynamicManagement();
-                                    baseDeviceDynamicManagement.setCameraCode(accountManagement.getCameraCode());
-                                    baseDeviceDynamicManagement.setUpdateBy(userId);
-                                    baseDeviceDynamicManagement.setCreateBy(userId);
-                                    baseDeviceDynamicManagementMapper.insert(baseDeviceDynamicManagement);
-                                    successNum++;
-                                    successMsg.append(successNum + "、相机编码 " + accountManagement.getCameraCode() + " 导入成功");
-                                }
-                            }
+                                baseCameraManagementMapper.insert(accountManagement);
+                                BaseDeviceDynamicManagement baseDeviceDynamicManagement = new BaseDeviceDynamicManagement();
+                                baseDeviceDynamicManagement.setCameraCode(accountManagement.getCameraCode());
+                                baseDeviceDynamicManagement.setUpdateBy(userId);
+                                baseDeviceDynamicManagement.setCreateBy(userId);
+                                baseDeviceDynamicManagementMapper.insert(baseDeviceDynamicManagement);
+                                successNum++;
+                                successMsg.append(successNum + "、相机编码 " + accountManagement.getCameraCode() + " 导入成功");
                         } else {
                             failureNum++;
                             String msg = failureNum + "、相机所属线路名称 " + accountManagement.getRailwayName() + "不存在, 导入失败:";

+ 11 - 11
business-service/src/main/java/com/ozs/service/service/impl/BaseCameraVersionServiceImpl.java

@@ -158,17 +158,17 @@ public class BaseCameraVersionServiceImpl extends ServiceImpl<BaseCameraVersionM
                 it.remove();
             }
         }
-        if ("3".equals(baseCameraVersionVo.getUpgradeType())){
-            log.info("cameraVersionUpgrade--------3");
-            List<BaseVersionCameraParam> baseVersionCameraParamList = baseCameraVersionVo.getBaseVersionCameraParamList();
-            for (BaseVersionCameraParam baseVersionCameraParam : baseVersionCameraParamList) {
-                if ("threshold".equals(baseVersionCameraParam.getParamKey())) {
-                    PublishClient.confidenceCoefficient(baseCameraVersionVo, baseVersionCameraParam.getParamValue());
-                } else if ("fps".equals(baseVersionCameraParam.getParamKey())) {
-                    PublishClient.configFrameRate(baseCameraVersionVo, baseVersionCameraParam.getParamValue());
-                }
-            }
-        }
+//        if ("3".equals(baseCameraVersionVo.getUpgradeType())){
+//            log.info("cameraVersionUpgrade--------3");
+//            List<BaseVersionCameraParam> baseVersionCameraParamList = baseCameraVersionVo.getBaseVersionCameraParamList();
+//            for (BaseVersionCameraParam baseVersionCameraParam : baseVersionCameraParamList) {
+//                if ("threshold".equals(baseVersionCameraParam.getParamKey())) {
+//                    PublishClient.confidenceCoefficient(baseCameraVersionVo, baseVersionCameraParam.getParamValue());
+//                } else if ("fps".equals(baseVersionCameraParam.getParamKey())) {
+//                    PublishClient.configFrameRate(baseCameraVersionVo, baseVersionCameraParam.getParamValue());
+//                }
+//            }
+//        }
         PublishClient.updateDeviceSn(baseCameraVersionVo);
         return AjaxResult.success("已经为您提交升级申请,请您到“日志管理>相机升级日志”页面查看升级结果。");
     }

+ 2 - 0
business-service/src/main/java/com/ozs/service/service/impl/CameraCaptureService.java

@@ -5,11 +5,13 @@ import com.ozs.common.utils.uuid.IdUtils;
 import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.io.*;
 import java.net.HttpURLConnection;
+import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.util.Date;
 

+ 1 - 8
business-service/src/main/java/com/ozs/service/utils/PublishCallback.java

@@ -93,14 +93,7 @@ public class PublishCallback implements MqttCallback {
                 for (int i = 0; i < jsonArray.size(); i++) {
                     JSONObject object = jsonArray.getJSONObject(i);
                     code = (Integer) object.get("code");
-                    deviceSn = (String) object.get("device_sn");
-                    sign = (String) object.get("sign");
-                }
-                if (sign.startsWith("rate") && code == 400) {
-                    CallbackUtil.callback(deviceSn, code, "帧率升级失败");
-                }
-                if (sign.startsWith("cien") && code == 400) {
-                    CallbackUtil.callback(deviceSn, code, "置信度升级失败");
+                    logger.info("code-------->" + code);
                 }
                 CallbackUtil.callback(deviceSn, code, "");
             } catch (Exception e) {

+ 46 - 30
business-service/src/main/java/com/ozs/service/utils/PublishClient.java

@@ -2,17 +2,13 @@ package com.ozs.service.utils;
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.filter.Filter;
+import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
 import com.ozs.common.utils.sign.Md5Utils;
 import com.ozs.common.utils.stateSecrets.SM4Utils;
 import com.ozs.common.utils.uuid.IdUtils;
-import com.ozs.service.entity.vo.BaseCameraVersionVo;
-import com.ozs.service.entity.vo.Codec;
-import com.ozs.service.entity.vo.Data;
-import com.ozs.service.entity.vo.Heartbeat;
-import com.ozs.service.entity.vo.Param;
-import com.ozs.service.entity.vo.Svp;
-import com.ozs.service.entity.vo.UpdateDeviceSn;
-import com.ozs.service.entity.vo.Venc0;
+import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.vo.*;
 import lombok.extern.slf4j.Slf4j;
 import org.eclipse.paho.client.mqttv3.MqttClient;
 import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
@@ -110,6 +106,26 @@ public class PublishClient {
         publish(getMqttTopic("heart_" + deviceSn), message);
     }
 
+    public static void main(String[] args) {
+        JSONObject res = new JSONObject();
+        res.put("Name", "ConfigRequest");
+        Codec codec = new Codec();
+        Venc venc = new Venc();
+        venc.setFps(Double.valueOf(11));
+        ArrayList<Venc> vencList = new ArrayList<>();
+        vencList.add(venc);
+        codec.setVenc(vencList);
+        Map<String, Object> map = new HashMap<>();
+        res.put("device_sn", "11");
+        res.put("sign", "rate" + IdUtils.fastSimpleUUID());
+        map.put("codec",codec);
+        res.put("data", map);
+        String s = JSONObject.toJSONString(res);
+
+        System.out.println(s);
+
+    }
+
     public static void updateDeviceSn(BaseCameraVersionVo baseCameraVersionVo) {
         /**
          * 发布客户端
@@ -149,20 +165,23 @@ public class PublishClient {
         }
     }
 
-    public static void confidenceCoefficient(BaseCameraVersionVo baseCameraVersionVo, String value) {
+    public static void confidenceCoefficient(BaseCameraManagement baseCameraManagement, String value) {
         /**
          * 发布客户端
          */
-        for (String code : baseCameraVersionVo.getCameraCodeList()) {
             try {
                 JSONObject res = new JSONObject();
-                res.put("Name", "ConfigRequest");
-                Svp svp = new Svp();
-                Param param = new Param();
-                param.setThreshold(Double.valueOf(value));
-                svp.setParam(param);
+                res.put("Name", "HeartRequest");
+                Codec codec = new Codec();
+                Venc venc = new Venc();
+                venc.setFps(Double.valueOf(value));
+                ArrayList<Venc> vencList = new ArrayList<>();
+                vencList.add(venc);
+                codec.setVenc(vencList);
                 Map<String, Object> map = new HashMap<>();
-                map.put("svp", svp);
+                res.put("device_sn", baseCameraManagement.getCameraSn());
+                res.put("sign", "rate" + IdUtils.fastSimpleUUID());
+                map.put("codec",codec);
                 res.put("data", map);
                 res.put("sign", "cien" + IdUtils.fastSimpleUUID());
                 String s = JSONObject.toJSONString(res);
@@ -175,7 +194,7 @@ public class PublishClient {
                 /**
                  * 消息保留
                  */
-//               message.setRetained(false);
+//              message.setRetained(false);
                 /**
                  * 消息内容
                  */
@@ -183,31 +202,29 @@ public class PublishClient {
                 /**
                  * 发布
                  */
-                publish(getMqttTopic("config_" + code), message);
+                publish(getMqttTopic("config_" + baseCameraManagement.getCameraCode()), message);
             } catch (MqttException e) {
                 System.out.println(e.getMessage());
             }
-        }
     }
 
-    public static void configFrameRate(BaseCameraVersionVo baseCameraVersionVo, String value) {
+    public static void configFrameRate(BaseCameraManagement baseCameraManagement,Integer mode) {
         /**
          * 发布客户端
          */
-        for (String code : baseCameraVersionVo.getCameraCodeList()) {
             try {
                 JSONObject res = new JSONObject();
-                res.put("Name", "ConfigRequest");
+                res.put("Name", "HeartRequest");
                 Codec codec = new Codec();
-                Venc0 venc0 = new Venc0();
-                venc0.setFps(Double.valueOf(value));
-                codec.setVenc0(venc0);
+                Day2night day2night = new Day2night();
+                day2night.setMode(mode);
+                codec.setDay2night(day2night);
                 Map<String, Object> map = new HashMap<>();
-                map.put("codec", codec);
-                res.put("data", map);
+                res.put("device_sn", baseCameraManagement.getCameraSn());
                 res.put("sign", "rate" + IdUtils.fastSimpleUUID());
+                map.put("codec",codec);
+                res.put("data", map);
                 String s = JSONObject.toJSONString(res);
-
                 MqttMessage message = new MqttMessage();
                 /**
                  * 保证消息能到达一次
@@ -224,11 +241,10 @@ public class PublishClient {
                 /**
                  * 发布
                  */
-                publish(getMqttTopic("config_" + code), message);
+                publish(getMqttTopic("config_" + baseCameraManagement.getCameraCode()), message);
             } catch (MqttException e) {
                 System.out.println(e.getMessage());
             }
-        }
     }
 
     @PostConstruct

+ 3 - 0
business-service/src/main/resources/mapper/service/BaseCameraManagementMapper.xml

@@ -55,6 +55,9 @@
             <if test="installMile != null and installMile != 0">
                 and a.install_mile =#{installMile}
             </if>
+            <if test="railwayType != null and railwayType != 0">
+                and r.railway_type =#{railwayType}
+            </if>
             <if test="ids != null and ids.size>0">
                 and a.id in
                 <foreach item="items" collection="ids" separator="," open="(" close=")" index="">

+ 45 - 14
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -22,18 +22,10 @@ import com.ozs.common.utils.file.FileUtils;
 import com.ozs.common.utils.http.HttpUtils;
 import com.ozs.common.utils.poi.ExcelUtil;
 import com.ozs.framework.config.ServerConfig;
-import com.ozs.service.entity.BaseCameraManagement;
-import com.ozs.service.entity.BaseDeviceDynamicManagement;
-import com.ozs.service.entity.BaseRailwayManagement;
-import com.ozs.service.entity.BaseUser;
-import com.ozs.service.entity.CameraTree;
-import com.ozs.service.entity.MsgAlarm;
+import com.ozs.service.entity.*;
 import com.ozs.service.entity.vo.*;
-import com.ozs.service.service.BaseCameraManagementService;
-import com.ozs.service.service.BaseDeviceDynamicManagementService;
-import com.ozs.service.service.BaseRailwayManagementService;
-import com.ozs.service.service.BaseUserService;
-import com.ozs.service.service.MsgAlarmService;
+import com.ozs.service.service.*;
+import com.ozs.service.utils.PublishClient;
 import com.ozs.system.service.DataScoreUtil;
 import com.ozs.system.service.ISysDeptService;
 import com.ozs.system.service.ISysDictTypeService;
@@ -102,6 +94,8 @@ public class BaseCameraManagementController extends BaseController {
     private ISysDictTypeService dictTypeService;
     @Autowired
     private CameraUtil cameraUtil;
+    @Autowired
+    private MqLogService mqLogService;
 
 
     /**
@@ -142,6 +136,17 @@ public class BaseCameraManagementController extends BaseController {
                 String begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
                 baseCameraManagement.setBeginMiles(begin);
             }
+            BaseDeviceDynamicManagement deviceDynamicManagement = baseDeviceDynamicManagementService.getOne(new LambdaQueryWrapper<BaseDeviceDynamicManagement>()
+                    .eq(BaseDeviceDynamicManagement::getCameraCode, cameraCode));
+            if (deviceDynamicManagement.getIsDisable()==2) {
+                baseCameraManagement.setIsDisable(deviceDynamicManagement.getIsDisable());
+                baseCameraManagement.setElectricity(deviceDynamicManagement.getElectricity());
+                List<MqLog> list = mqLogService.list(new LambdaQueryWrapper<MqLog>()
+                        .eq(MqLog::getCameraCode, cameraCode));
+                if (!ObjectUtils.isEmpty(list)) {
+                    baseCameraManagement.setHeartTime(list.get(0).getCreateTime());
+                }
+            }
             return AjaxResult.success(baseCameraManagement);
         } else if (!StringUtils.isEmpty(isLock) && isLock == 2 && !StringUtils.isEmpty(cameraCode)) {
             MsgAlarm msgAlarm = msgAlarmService.selectByCameraCode(cameraCode);
@@ -980,13 +985,39 @@ public class BaseCameraManagementController extends BaseController {
      *
      * @return
      */
-    @GetMapping("/removePrice")
-    public AjaxResult removePrice() {
-        log.info("测试minio删除图片");
+    @GetMapping("/removePrice/{number}")
+    public AjaxResult removePrice(@PathVariable Integer number) {
+        log.info("removePrice");
         cameraUtil.test();
         return success();
     }
 
+    /**
+     * 夜视
+     * @param deviceStateResp
+     * @return
+     */
+    @GetMapping("/nightVision/{code}/{mode}")
+    public AjaxResult nightVision(@PathVariable String code,Integer mode){
+        BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(new LambdaQueryWrapper<BaseCameraManagement>()
+                .eq(BaseCameraManagement::getCameraCode, code));
+        PublishClient.configFrameRate(baseCameraManagement,mode);
+        return success();
+    }
+
+    /**
+     * 切换帧率
+     * @param code
+     * @return
+     */
+    @GetMapping("/switchFrameRate")
+    public AjaxResult switchFrameRate(@RequestParam("code") String code,@RequestParam("fps") String fps){
+        BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(new LambdaQueryWrapper<BaseCameraManagement>()
+                .eq(BaseCameraManagement::getCameraCode, code));
+        PublishClient.confidenceCoefficient(baseCameraManagement,fps);
+        return success();
+    }
+
     /**
      * 设备状态页面
      *