Przeglądaj źródła

Merge branch 'master' of http://124.70.58.209:3000/ytrd-project-management/GeoHazardMonitor

wyyay 1 rok temu
rodzic
commit
5bc085a8f4

+ 2 - 2
business-service/src/main/java/com/ozs/service/entity/BaseVersionCameraParam.java

@@ -34,11 +34,11 @@ public class BaseVersionCameraParam {
     /**
      * key
      */
-    private String key;
+    private String paramKey;
     /**
      * value
      */
-    private String value;
+    private String paramValue;
     /**
      * 创建人
      */

+ 6 - 0
business-service/src/main/java/com/ozs/service/entity/CameraLogDetail.java

@@ -75,4 +75,10 @@ public class CameraLogDetail implements Serializable {
      */
     @Excel(name = "备注")
     private String remark;
+
+    /**
+     * 升级失败原因failure_reason
+     */
+    @Excel(name = "升级失败原因")
+    private String failureReason;
 }

+ 1 - 0
business-service/src/main/java/com/ozs/service/entity/vo/BaseCameraVersionVo.java

@@ -68,6 +68,7 @@ public class BaseCameraVersionVo {
     /**
      * 创建时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
     /**

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

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

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

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

+ 12 - 0
business-service/src/main/java/com/ozs/service/service/BaseVersionCameraParamService.java

@@ -0,0 +1,12 @@
+package com.ozs.service.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ozs.service.entity.BaseCameraVersion;
+import com.ozs.service.entity.BaseVersionCameraParam;
+
+/**
+ * @Author : sunhh
+ * @create 2023/4/26 16:12
+ */
+public interface BaseVersionCameraParamService extends IService<BaseVersionCameraParam> {
+}

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

@@ -42,6 +42,7 @@ public class BaseCameraVersionServiceImpl extends ServiceImpl<BaseCameraVersionM
     private BaseVersionCameraParamMapper baseVersionCameraParamMapper;
 
     @Override
+    @Transactional
     public AjaxResult cameraVersionAdd(BaseCameraVersion baseCameraVersion, String userId) {
         LambdaQueryWrapper<BaseCameraVersion> wrapper = new LambdaQueryWrapper<>();
         if (!StringUtils.isEmptySunhh(baseCameraVersion) && !StringUtils.isEmptySunhh(baseCameraVersion.getVersionNum())) {
@@ -139,6 +140,18 @@ public class BaseCameraVersionServiceImpl extends ServiceImpl<BaseCameraVersionM
             cameraLogDetail.setUpdateTime(new Date());
             int insert = cameraLogDetailMapper.insert(cameraLogDetail);
         }
+        if ("3".equals(baseCameraVersionVo.getUpgradeType())){
+            List<BaseVersionCameraParam> baseVersionCameraParamList = baseCameraVersionVo.getBaseVersionCameraParamList();
+            for (BaseVersionCameraParam baseVersionCameraParam : baseVersionCameraParamList) {
+                if ("threshold".equals(baseVersionCameraParam.getParamKey())){
+                    PublishClient.confidenceCoefficient(baseCameraVersionVo,baseVersionCameraParam.getParamValue());
+                    new SubscribeClient("config", "config").start();
+                }else if("fps".equals(baseVersionCameraParam.getParamKey())){
+                    PublishClient.configFrameRate(baseCameraVersionVo,baseVersionCameraParam.getParamValue());
+                    new SubscribeClient("config", "config").start();
+                }
+            }
+        }
         PublishClient.updateDeviceSn(baseCameraVersionVo);
         new SubscribeClient("update", "update").start();
         return AjaxResult.success();

+ 18 - 0
business-service/src/main/java/com/ozs/service/service/impl/BaseVersionCameraParamServiceImpl.java

@@ -0,0 +1,18 @@
+package com.ozs.service.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.BaseVersionCameraParam;
+import com.ozs.service.mapper.BaseCameraManagementMapper;
+import com.ozs.service.mapper.BaseVersionCameraParamMapper;
+import com.ozs.service.service.BaseCameraManagementService;
+import com.ozs.service.service.BaseVersionCameraParamService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author : sunhh
+ * @create 2023/4/26 16:15
+ */
+@Service
+public class BaseVersionCameraParamServiceImpl extends ServiceImpl<BaseVersionCameraParamMapper, BaseVersionCameraParam> implements BaseVersionCameraParamService {
+}

+ 10 - 0
business-service/src/main/java/com/ozs/service/utils/PublishCallback.java

@@ -66,6 +66,16 @@ public class PublishCallback implements MqttCallback {
                 deviceSn = (String) object.get("device_sn");
             }
             CallbackUtil.callback(deviceSn,code);
+        }if ("config".equals(topic)){
+            String s = new String(message.getPayload());
+            s = "[" + s + "]";
+            JSONArray jsonArray = JSONArray.parseArray(s);
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject object = jsonArray.getJSONObject(i);
+                code = (Integer) object.get("code");
+                deviceSn = (String) object.get("device_sn");
+            }
+            CallbackUtil.callback(deviceSn,code);
         }
         System.out.println("接收消息内容 : " + new String(message.getPayload()));
         

+ 78 - 32
business-service/src/main/java/com/ozs/service/utils/PublishClient.java

@@ -5,11 +5,13 @@ import com.alibaba.fastjson2.JSONObject;
 import com.ozs.common.utils.sign.Md5Utils;
 import com.ozs.common.utils.stateSecrets.SM4Utils;
 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 org.eclipse.paho.client.mqttv3.MqttClient;
 import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
 import org.eclipse.paho.client.mqttv3.MqttDeliveryToken;
@@ -191,43 +193,87 @@ public class PublishClient {
         }
     }
 
-    public static void confidenceCoefficient(String code) {
+    public static void confidenceCoefficient(BaseCameraVersionVo baseCameraVersionVo,String value) {
         /**
          * 发布客户端
          */
-        try {
-            PublishClient server = new PublishClient("config_" + code, "config_" + code);
-            JSONObject res = new JSONObject();
-            res.put("Name", "ConfigRequest");
-            Svp svp=new Svp();
-            Param param = new Param();
-            param.setThreshold(0.700000);
-            svp.setParam(param);
-            Map<String,Object> map=new HashMap<>();
-            map.put("svp",svp);
-            res.put("data",map);
-            res.put("sign",UUID.randomUUID().toString());
-            String s = JSONObject.toJSONString(res);
+        for (String code : baseCameraVersionVo.getCameraCodeList()) {
+            try {
+                PublishClient server = new PublishClient("config_" + code, "config_" + code);
+                JSONObject res = new JSONObject();
+                res.put("Name", "ConfigRequest");
+                Svp svp = new Svp();
+                Param param = new Param();
+                param.setThreshold(Double.valueOf(value));
+                svp.setParam(param);
+                Map<String, Object> map = new HashMap<>();
+                map.put("svp", svp);
+                res.put("data", map);
+                res.put("sign", UUID.randomUUID().toString());
+                String s = JSONObject.toJSONString(res);
 
-            server.message = new MqttMessage();
-            /**
-             * 保证消息能到达一次
-             */
-            server.message.setQos(1);
-            /**
-             * 消息保留
-             */
+                server.message = new MqttMessage();
+                /**
+                 * 保证消息能到达一次
+                 */
+                server.message.setQos(1);
+                /**
+                 * 消息保留
+                 */
 //                server.message.setRetained(false);
-            /**
-             * 消息内容
-             */
-            server.message.setPayload(s.getBytes());
-            /**
-             * 发布
-             */
-            server.publish(server.topic11, server.message);
-        } catch (MqttException e) {
-            System.out.println(e.getMessage());
+                /**
+                 * 消息内容
+                 */
+                server.message.setPayload(s.getBytes());
+                /**
+                 * 发布
+                 */
+                server.publish(server.topic11, server.message);
+            } catch (MqttException e) {
+                System.out.println(e.getMessage());
+            }
+        }
+    }
+
+    public static void configFrameRate(BaseCameraVersionVo baseCameraVersionVo,String value) {
+        /**
+         * 发布客户端
+         */
+        for (String code : baseCameraVersionVo.getCameraCodeList()) {
+            try {
+                PublishClient server = new PublishClient("config_" + code, "config_" + code);
+                JSONObject res = new JSONObject();
+                res.put("Name", "ConfigRequest");
+                Codec codec = new Codec();
+                Venc0 venc0 = new Venc0();
+                venc0.setFps(Double.valueOf(value));
+                codec.setVenc0(venc0);
+                Map<String, Object> map = new HashMap<>();
+                map.put("codec", codec);
+                res.put("data", map);
+                res.put("sign", UUID.randomUUID().toString());
+                String s = JSONObject.toJSONString(res);
+
+                server.message = new MqttMessage();
+                /**
+                 * 保证消息能到达一次
+                 */
+                server.message.setQos(1);
+                /**
+                 * 消息保留
+                 */
+//                server.message.setRetained(false);
+                /**
+                 * 消息内容
+                 */
+                server.message.setPayload(s.getBytes());
+                /**
+                 * 发布
+                 */
+                server.publish(server.topic11, server.message);
+            } catch (MqttException e) {
+                System.out.println(e.getMessage());
+            }
         }
     }
 }

+ 15 - 3
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraVersionController.java

@@ -10,10 +10,12 @@ import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.bean.BeanUtils;
 import com.ozs.service.entity.BaseCameraManagement;
 import com.ozs.service.entity.BaseCameraVersion;
+import com.ozs.service.entity.BaseVersionCameraParam;
 import com.ozs.service.entity.vo.BaseCameraManagementHomeVo;
 import com.ozs.service.entity.vo.BaseCameraVersionVo;
 import com.ozs.service.service.BaseCameraManagementService;
 import com.ozs.service.service.BaseCameraVersionService;
+import com.ozs.service.service.BaseVersionCameraParamService;
 import com.ozs.system.service.ISysDictDataService;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -41,6 +43,8 @@ public class BaseCameraVersionController extends BaseController {
     private BaseCameraManagementService baseCameraManagementService;
     @Autowired
     private ISysDictDataService dictDataService;
+    @Autowired
+    private BaseVersionCameraParamService baseVersionCameraParamService;
 
     /**
      * 相机版本管理 版本升级
@@ -93,11 +97,19 @@ public class BaseCameraVersionController extends BaseController {
             List<BaseCameraVersionVo> dto1 = page.getResult().stream().map(o -> {
                 BaseCameraVersionVo baseCameraVersionVo1 = new BaseCameraVersionVo();
                 BeanUtils.copyProperties(o, baseCameraVersionVo1);
-                // 升级类型 1:算法升级,2:硬件升级,3:算法及硬件升级
+                // 升级类型 0.固件 1.算法 2:算法及硬件升级 3:摄像头系统参数
                 String upgradeTypeName = dictDataService.selectDictLabel("upgrade_type", o.getUpgradeType());
                 if (!StringUtils.isEmptySunhh(upgradeTypeName)) {
                     baseCameraVersionVo1.setUpgradeTypename(upgradeTypeName);
                 }
+                if ("3".equals(o.getUpgradeType())) {
+                    LambdaQueryWrapper<BaseVersionCameraParam> wrapperBaseVersionCameraParam = new LambdaQueryWrapper<>();
+                    if (!StringUtils.isEmptySunhh(baseCameraVersionVo) && !StringUtils.isEmptySunhh(baseCameraVersionVo.getId())) {
+                        wrapperBaseVersionCameraParam.eq(BaseVersionCameraParam::getVersionId, baseCameraVersionVo.getId());
+                    }
+                    List<BaseVersionCameraParam> baseVersionCameraParams = baseVersionCameraParamService.list(wrapperBaseVersionCameraParam);
+                    baseCameraVersionVo1.setBaseVersionCameraParamList(baseVersionCameraParams);
+                }
                 return baseCameraVersionVo1;
             }).collect(Collectors.toList());
             pageR.setRecords(dto1);
@@ -117,8 +129,8 @@ public class BaseCameraVersionController extends BaseController {
     public AjaxResult cameraVersionAdd(@RequestBody BaseCameraVersion baseCameraVersion) {
         if (StringUtils.isEmptySunhh(baseCameraVersion) || StringUtils.isEmptySunhh(baseCameraVersion.getVersionNum())
                 || StringUtils.isEmptySunhh(baseCameraVersion.getVersionName())
-                || StringUtils.isEmptySunhh(baseCameraVersion.getVersionAddress())) {
-            return AjaxResult.error("相机版本号、版本名称、版本地址不能为空!");
+                || StringUtils.isEmptySunhh(baseCameraVersion.getUpgradeType())) {
+            return AjaxResult.error("相机版本号、版本名称、版本类型 不能为空!");
         }
         return baseCameraVersionService.cameraVersionAdd(baseCameraVersion, getUserId());
     }

+ 0 - 9
hazard-admin/src/main/java/com/ozs/web/controller/mqtt/MqttController.java

@@ -23,15 +23,6 @@ import org.springframework.web.bind.annotation.RestController;
 public class MqttController implements ApplicationRunner {
     
 
-    @ApiOperation(value = "置信度修改")
-    @GetMapping("/confidenceCoefficient")
-    @Log(title = "MQTT", businessType = BusinessType.SELECT)
-    public AjaxResult confidenceCoefficient() {
-        PublishClient.confidenceCoefficient("42010001541320000024");
-        new SubscribeClient("config", "config").start();
-        return AjaxResult.success();
-    }
-
     @Override
     public void run(ApplicationArguments args) throws Exception {
         new SubscribeClient("heart", "heart").start();