浏览代码

计算优先级配置接口,设置接口

lyhzzz 1 年之前
父节点
当前提交
798d8680d3

+ 0 - 21
src/main/java/com/fdkankan/manage/controller/MqCameraLevelController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.manage.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author 
- * @since 2024-04-17
- */
-@RestController
-@RequestMapping("/manage/mqCameraLevel")
-public class MqCameraLevelController {
-
-}
-

+ 0 - 21
src/main/java/com/fdkankan/manage/controller/MqNumLevelController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.manage.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author 
- * @since 2024-04-17
- */
-@RestController
-@RequestMapping("/manage/mqNumLevel")
-public class MqNumLevelController {
-
-}
-

+ 94 - 0
src/main/java/com/fdkankan/manage/controller/MqQueueConfigController.java

@@ -0,0 +1,94 @@
+package com.fdkankan.manage.controller;
+
+
+import com.fdkankan.manage.common.ResultCode;
+import com.fdkankan.manage.common.ResultData;
+import com.fdkankan.manage.entity.MqCameraLevel;
+import com.fdkankan.manage.entity.MqNumLevel;
+import com.fdkankan.manage.entity.MqQueueConfig;
+import com.fdkankan.manage.exception.BusinessException;
+import com.fdkankan.manage.service.IMqCameraLevelService;
+import com.fdkankan.manage.service.IMqNumLevelService;
+import com.fdkankan.manage.service.IMqQueueConfigService;
+import com.fdkankan.manage.vo.request.ModelingLevelParam;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2024-05-08
+ */
+@RestController
+@RequestMapping("/service/manage/mqQueueConfig")
+public class MqQueueConfigController {
+
+    @Autowired
+    IMqQueueConfigService queueConfigService;
+
+    @PostMapping("/allList")
+    public ResultData allList(){
+        return ResultData.ok(queueConfigService.getNormalConfig());
+    }
+
+
+    @Autowired
+    IMqCameraLevelService mqCameraLevelService;
+    @Autowired
+    IMqNumLevelService mqNumLevelService;
+
+    @GetMapping("/getInfo")
+    public ResultData getInfo(@RequestParam(required = false) String num ,@RequestParam(required = false) Long cameraId){
+        if(StringUtils.isBlank(num) && cameraId == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        if(StringUtils.isNotBlank(num)){
+            MqNumLevel byNum = mqNumLevelService.getByNum(num);
+            if(byNum != null){
+                return ResultData.ok(queueConfigService.getById(byNum.getQueueConfigId()));
+            }
+        }
+        if(cameraId != null){
+            MqCameraLevel byCameraId = mqCameraLevelService.getByCameraId(cameraId);
+            if(byCameraId != null){
+                return ResultData.ok(queueConfigService.getById(byCameraId.getQueueConfigId()));
+            }
+        }
+        return ResultData.ok(queueConfigService.getDefaultConfig());
+    }
+
+    /**
+     * 修改场景或相机计算优先级
+     */
+    @PostMapping("/updateModelingLevel")
+    public ResultData updateModelingLevel(@RequestBody ModelingLevelParam param){
+        if(param.getConfigId() == null && (param.getCameraId() == null || StringUtils.isBlank(param.getNum()))){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        if(param.getCameraId() != null){
+            MqCameraLevel cameraLevel = mqCameraLevelService.getByCameraId(param.getCameraId());
+            if(cameraLevel == null){
+                mqCameraLevelService.saveEntity(param.getCameraId(),param.getConfigId());
+            }else {
+                mqCameraLevelService.updateLevelById(cameraLevel.getId(),param.getConfigId());
+            }
+        }
+        if(StringUtils.isNotBlank(param.getNum())){
+            MqNumLevel mqNumLevel = mqNumLevelService.getByNum(param.getNum());
+            if(mqNumLevel == null){
+                mqNumLevelService.saveEntity(param.getNum(),param.getConfigId());
+            }else {
+                mqNumLevelService.updateLevelById(mqNumLevel.getId(),param.getConfigId());
+            }
+        }
+
+        return ResultData.ok();
+    }
+}
+

+ 1 - 4
src/main/java/com/fdkankan/manage/controller/SceneController.java

@@ -4,12 +4,9 @@ package com.fdkankan.manage.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.manage.common.ResultCode;
-import com.fdkankan.manage.entity.SceneCopyLog;
-import com.fdkankan.manage.entity.ScenePlusExt;
+import com.fdkankan.manage.entity.*;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.common.ResultData;
-import com.fdkankan.manage.entity.ScenePlus;
-import com.fdkankan.manage.entity.ScenePro;
 import com.fdkankan.manage.httpClient.client.FdKKClient;
 import com.fdkankan.manage.service.*;
 import com.fdkankan.manage.vo.request.SceneParam;

+ 102 - 0
src/main/java/com/fdkankan/manage/entity/MqQueueConfig.java

@@ -0,0 +1,102 @@
+package com.fdkankan.manage.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2024-05-08
+ */
+@Getter
+@Setter
+@TableName("mq_queue_config")
+public class MqQueueConfig implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * mq队列名称
+     */
+    @TableField("queue_name")
+    private String queueName;
+
+    /**
+     * 是否开启弹性伸缩0否,1是
+     */
+    @TableField("open_scaling")
+    private Integer openScaling;
+
+    /**
+     * 开启弹性伸缩阈值
+     */
+    @TableField("scaling_threshold")
+    private Integer scalingThreshold;
+
+    /**
+     * 检测是否需要开启间隔时间,单位分钟
+     */
+    @TableField("open_scaling_time")
+    private Integer openScalingTime;
+
+    /**
+     * 检测关闭弹性伸缩时间间隔,单位分钟
+     */
+    @TableField("stop_scaling_time")
+    private Integer stopScalingTime;
+
+    @TableField("scaling_config_id")
+    private Integer scalingConfigId;
+
+    @TableField("remark")
+    private String remark;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A",delval = "I")
+    private String recStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 计算优先等级
+     */
+    @TableField("level")
+    private String level;
+
+    /**
+     * 是否默认0否1是
+     */
+    @TableField("is_default")
+    private Integer isDefault;
+
+    /**
+     * 是否常驻队列
+     */
+    @TableField("is_resident")
+    private Integer isResident;
+
+    /**
+     * 特殊处理队列0否,1是,例如128G
+     */
+    @TableField("is_special")
+    private Integer isSpecial;
+
+
+}

+ 1 - 1
src/main/java/com/fdkankan/manage/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir");
 
         generate(path,"manage", getTables(new String[]{
-                "t_rtk_info",
+                "mq_queue_config",
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 18 - 0
src/main/java/com/fdkankan/manage/mapper/IMqQueueConfigMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.manage.mapper;
+
+import com.fdkankan.manage.entity.MqQueueConfig;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2024-05-08
+ */
+@Mapper
+public interface IMqQueueConfigMapper extends BaseMapper<MqQueueConfig> {
+
+}

+ 21 - 0
src/main/java/com/fdkankan/manage/service/IMqQueueConfigService.java

@@ -0,0 +1,21 @@
+package com.fdkankan.manage.service;
+
+import com.fdkankan.manage.entity.MqQueueConfig;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2024-05-08
+ */
+public interface IMqQueueConfigService extends IService<MqQueueConfig> {
+
+    List<MqQueueConfig> getNormalConfig();
+
+    MqQueueConfig getDefaultConfig();
+}

+ 36 - 0
src/main/java/com/fdkankan/manage/service/impl/MqQueueConfigServiceImpl.java

@@ -0,0 +1,36 @@
+package com.fdkankan.manage.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.manage.entity.MqQueueConfig;
+import com.fdkankan.manage.mapper.IMqQueueConfigMapper;
+import com.fdkankan.manage.service.IMqQueueConfigService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2024-05-08
+ */
+@Service
+public class MqQueueConfigServiceImpl extends ServiceImpl<IMqQueueConfigMapper, MqQueueConfig> implements IMqQueueConfigService {
+
+    @Override
+    public List<MqQueueConfig> getNormalConfig() {
+        LambdaQueryWrapper<MqQueueConfig> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(MqQueueConfig::getIsSpecial,0);
+        return this.list(wrapper);
+    }
+
+    @Override
+    public MqQueueConfig getDefaultConfig() {
+        LambdaQueryWrapper<MqQueueConfig> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(MqQueueConfig::getIsDefault,1);
+        return this.getOne(wrapper);
+    }
+}

+ 5 - 0
src/main/resources/mapper/manage/MqQueueConfigMapper.xml

@@ -0,0 +1,5 @@
+<?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.fdkankan.manage.mapper.IMqQueueConfigMapper">
+
+</mapper>