Browse Source

相机截图开发

gao.qiang 1 tháng trước cách đây
mục cha
commit
7a7860093e

+ 1 - 4
business-service/src/main/java/com/ozs/service/service/impl/BaseCameraManagementServiceImpl.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.pagehelper.PageHelper;
 import com.ozs.common.core.domain.AjaxResult;
-import com.ozs.common.core.redis.RedisCache;
 import com.ozs.common.exception.ServiceException;
 import com.ozs.common.exception.base.BaseException;
 import com.ozs.common.utils.AppendUtils;
@@ -62,8 +61,7 @@ public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManag
     private CameraUpdateLogMapper cameraUpdateLogMapper;
     @Autowired
     private BaseRailwayManagementMapper baseRailwayManagementMapper;
-    @Autowired
-    private RedisCache redisCache;
+
 
     /**
      * 相机台账管理表导入
@@ -166,7 +164,6 @@ public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManag
             }
         }
         if (failureNum > 0) {
-            redisCache.deleteObject("screenshot");
             failureMsg.insert(0, "很抱歉!需导入数据共有" + accountManageList.size() + "条。数据导入成功共 " + successNum + " 条。数据导入失败共 " + failureNum + " 条。错误如下:");
             throw new ServiceException(failureMsg.toString());
         } else {

+ 0 - 4
business-service/src/main/java/com/ozs/service/service/impl/BaseRailwayManagementServiceImpl.java

@@ -2,7 +2,6 @@ package com.ozs.service.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ozs.common.core.redis.RedisCache;
 import com.ozs.common.exception.ServiceException;
 import com.ozs.common.utils.bean.BeanValidators;
 import com.ozs.service.entity.BaseRailwayManagement;
@@ -31,8 +30,6 @@ public class BaseRailwayManagementServiceImpl extends ServiceImpl<BaseRailwayMan
     BaseRailwayManagementMapper baseRailwayManagementMapper;
     @Autowired
     protected Validator validator;
-    @Autowired
-    private RedisCache redisCache;
 
     /**
      * 导出线路管理表信息
@@ -96,7 +93,6 @@ public class BaseRailwayManagementServiceImpl extends ServiceImpl<BaseRailwayMan
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
             throw new ServiceException(failureMsg.toString());
         } else {
-            redisCache.deleteObject("screenshot");
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条。");
         }
         return successMsg.toString();

+ 0 - 47
business-service/src/main/java/com/ozs/service/utils/CallbackUtil.java

@@ -36,61 +36,14 @@ public class CallbackUtil {
     CameraLogDetailService cameraLogDetailService;
     @Autowired
     MqLogService mqLogService;
-    @Autowired
-    private RedisCache redisCache;
-    @Autowired
-    BaseCameraManagementService baseCameraManagementService;
-    @Autowired
-    BaseRailwayManagementService baseRailwayManagementService;
-    @Value("${base.imgUrl}")
-    private String imgUrl;
     private static CameraLogDetailService cameraLogDetail;
     private static MqLogService mqLog;
-    private static RedisCache redis;
-    private static BaseCameraManagementService baseCameraManagement;
-    private static BaseRailwayManagementService baseRailwayManagement;
-    public static String url;
 
 
-    public static String screenshot(String deviceSn, String stream, String imageUrl) {
-        String path = null;
-        Map<String, Object> screenshot = redis.getCacheMap("screenshot");
-        if (ObjectUtils.isEmpty(screenshot)) {
-            List<BaseCameraManagement> list = baseCameraManagement.list();
-            Map<String, String> map = new HashMap<>();
-            for (BaseCameraManagement came : list) {
-                BaseRailwayManagement baseRailwayManagementOne = baseRailwayManagement.getOne(new LambdaQueryWrapper<BaseRailwayManagement>()
-                        .eq(BaseRailwayManagement::getRailwayCode, came.getRailwayCode()));
-                map.put(came.getCameraCode(), "/" + baseRailwayManagementOne.getRailwayName() + "/" + AppendUtils.stringAppend(came.getInstallMile()) + "/");
-                if (came.equals(deviceSn)) {
-                    path = url + "/" + baseRailwayManagementOne.getRailwayName() + "/" + AppendUtils.stringAppend(came.getInstallMile()) + "/" + LocalDate.now().getYear() + "/" + LocalDate.now().getMonthValue() + "/" + LocalDate.now().getDayOfMonth() + "/" + LocalTime.now().getHour() + "/" + imageUrl;
-                }
-            }
-            redis.setCacheMap("screenshot", map);
-            return path;
-        } else {
-            for (Map.Entry<String, Object> entry : screenshot.entrySet()) {
-                String key = entry.getKey();
-                Object value = entry.getValue();
-                // 将Object转换为String
-                if (key.equals(deviceSn)) {
-                    String stringValue = value != null ? value.toString() : null;
-                    path = url + stringValue + LocalDate.now().getYear() + "/" + LocalDate.now().getMonthValue() + "/" + LocalDate.now().getDayOfMonth() + "/" + LocalTime.now().getHour() + "/" + imageUrl;
-                    return path;
-                }
-            }
-        }
-        return  null;
-    }
-
     @PostConstruct
     public void init() {
         cameraLogDetail = cameraLogDetailService;
         mqLog = mqLogService;
-        redis = redisCache;
-        baseCameraManagement = baseCameraManagementService;
-        baseRailwayManagement = baseRailwayManagementService;
-        url = imgUrl;
     }
 
     public static void callback(String deviceSn, Integer code, String remark) {

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

@@ -75,23 +75,6 @@ public class PublishCallback implements MqttCallback {
                 logger.error(e.getMessage());
             }
         }
-        if ("screenshot".equals(topic)) {
-            try {
-                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);
-                    deviceSn = (String) object.get("code");
-                    stream = (String) object.get("stream");
-                    imageUrl = (String) object.get("imageUrl");
-                }
-                String url = CallbackUtil.screenshot(deviceSn, stream, imageUrl);
-                PublishClient.screenshot(url, deviceSn);
-            } catch (Exception e) {
-                logger.error(e.getMessage());
-            }
-        }
         if ("update".equals(topic)) {
             try {
                 String s = new String(message.getPayload());

+ 0 - 27
business-service/src/main/java/com/ozs/service/utils/PublishClient.java

@@ -106,33 +106,6 @@ public class PublishClient {
     }
 
 
-    public static void screenshot(String url, String deviceSn) throws MqttException {
-        /**
-         * 发布客户端
-         */
-        Screenshot screenshot = new Screenshot();
-        screenshot.setCode(deviceSn);
-        screenshot.setUrl(url);
-        String s = JSON.toJSONString(screenshot);
-        MqttMessage message = new MqttMessage();
-        /**
-         * 保证消息能到达一次
-         */
-        message.setQos(1);
-        /**
-         * 消息保留
-         */
-//        server.message.setRetained(false);
-        /**
-         * 消息内容
-         */
-        message.setPayload(s.getBytes());
-        /**
-         * 发布
-         */
-        publish(getMqttTopic("screenshot_" + deviceSn), message);
-    }
-
     public static void main(String[] args) {
         JSONObject res = new JSONObject();
         res.put("Name", "ConfigRequest");

+ 0 - 3
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -285,7 +285,6 @@ public class BaseCameraManagementController extends BaseController {
             baseDeviceDynamicManagementService.remove(queryWrapper);
             baseCameraManagementService.removeById(accountManagementId);
         }
-        redisCache.deleteObject("screenshot");
         return AjaxResult.success();
     }
 
@@ -360,7 +359,6 @@ public class BaseCameraManagementController extends BaseController {
                 }
             }
             if (baseCameraManagementService.save(baseCameraManagement) && baseDeviceDynamicManagementService.save(baseDynamicManagement)) {
-                redisCache.deleteObject("screenshot");
                 return AjaxResult.success();
             } else {
                 return AjaxResult.error();
@@ -432,7 +430,6 @@ public class BaseCameraManagementController extends BaseController {
         LambdaUpdateWrapper<BaseCameraManagement> wrapper = new LambdaUpdateWrapper<>();
         wrapper.eq(BaseCameraManagement::getId, baseCameraManagement.getId());
         if (baseCameraManagementService.update(baseCameraManagement, wrapper) && baseDeviceDynamicManagementService.updateById(one)) {
-            redisCache.deleteObject("screenshot");
             return AjaxResult.success();
         }
         return AjaxResult.error();

+ 0 - 8
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseRailwayManagementController.java

@@ -7,11 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ozs.common.annotation.Log;
 import com.ozs.common.core.controller.BaseController;
 import com.ozs.common.core.domain.AjaxResult;
-import com.ozs.common.core.domain.entity.SysDept;
 import com.ozs.common.core.domain.entity.SysDictData;
-import com.ozs.common.core.redis.RedisCache;
 import com.ozs.common.enums.BusinessType;
-import com.ozs.common.utils.AppendUtils;
 import com.ozs.common.utils.ChineseToPingyin;
 import com.ozs.common.utils.IdempotenceUtils;
 import com.ozs.common.utils.StringUtils;
@@ -64,8 +61,6 @@ public class BaseRailwayManagementController extends BaseController {
     private BaseCameraManagementService baseCameraManagementService;
     @Autowired
     private IdempotenceUtils idempotenceUtils;
-    @Autowired
-    private RedisCache redisCache;
 
     /**
      * 线路管理表分页
@@ -121,7 +116,6 @@ public class BaseRailwayManagementController extends BaseController {
             }
         }
         if (baseRailwayManagementService.removeByIds(lineIds)) {
-            redisCache.deleteObject("screenshot");
             return AjaxResult.success();
         }
         return AjaxResult.error();
@@ -162,7 +156,6 @@ public class BaseRailwayManagementController extends BaseController {
             baseRailwayManagement.setCreateBy(getUserId());
             baseRailwayManagement.setUpdateBy(getUserId());
             if (baseRailwayManagementService.save(baseRailwayManagement)) {
-                redisCache.deleteObject("screenshot");
                 return AjaxResult.success();
             } else {
                 return AjaxResult.error();
@@ -214,7 +207,6 @@ public class BaseRailwayManagementController extends BaseController {
         baseRailwayManagement.setUpdateBy(getUserId());
         baseRailwayManagement.setUpdateTime(new Date());
         if (baseRailwayManagementService.updateById(baseRailwayManagement)) {
-            redisCache.deleteObject("screenshot");
             return AjaxResult.success();
         }
         return AjaxResult.error();