瀏覽代碼

计算优先级测试接口

lyhzzz 1 年之前
父節點
當前提交
2a161c8530

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

@@ -0,0 +1,21 @@
+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 {
+
+}
+

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

@@ -0,0 +1,21 @@
+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 {
+
+}
+

+ 57 - 0
src/main/java/com/fdkankan/manage/entity/MqCameraLevel.java

@@ -0,0 +1,57 @@
+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-04-17
+ */
+@Getter
+@Setter
+@TableName("mq_camera_level")
+public class MqCameraLevel implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 计算优先级设置
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 相机id
+     */
+    @TableField("camera_id")
+    private Long cameraId;
+
+    /**
+     * 计算优先级队列id
+     */
+    @TableField("queue_config_id")
+    private Integer queueConfigId;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A",delval = "I")
+    private String recStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 57 - 0
src/main/java/com/fdkankan/manage/entity/MqNumLevel.java

@@ -0,0 +1,57 @@
+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-04-17
+ */
+@Getter
+@Setter
+@TableName("mq_num_level")
+public class MqNumLevel implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 计算优先级设置
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 场景码
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 计算优先级队列id
+     */
+    @TableField("queue_config_id")
+    private Integer queueConfigId;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A",delval = "I")
+    private String recStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

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

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

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

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

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

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

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

@@ -0,0 +1,21 @@
+package com.fdkankan.manage.service;
+
+import com.fdkankan.manage.entity.MqCameraLevel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2024-04-17
+ */
+public interface IMqCameraLevelService extends IService<MqCameraLevel> {
+
+    MqCameraLevel getByCameraId(Long cameraId);
+
+    void saveEntity(Long cameraId, Integer configId);
+
+    void updateLevelById(Integer id, Integer configId);
+}

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

@@ -0,0 +1,21 @@
+package com.fdkankan.manage.service;
+
+import com.fdkankan.manage.entity.MqNumLevel;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2024-04-17
+ */
+public interface IMqNumLevelService extends IService<MqNumLevel> {
+
+    MqNumLevel getByNum(String num);
+
+    void saveEntity(String num, Integer configId);
+
+    void updateLevelById(Integer id, Integer configId);
+}

+ 44 - 0
src/main/java/com/fdkankan/manage/service/impl/MqCameraLevelServiceImpl.java

@@ -0,0 +1,44 @@
+package com.fdkankan.manage.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.manage.entity.MqCameraLevel;
+import com.fdkankan.manage.mapper.IMqCameraLevelMapper;
+import com.fdkankan.manage.service.IMqCameraLevelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2024-04-17
+ */
+@Service
+public class MqCameraLevelServiceImpl extends ServiceImpl<IMqCameraLevelMapper, MqCameraLevel> implements IMqCameraLevelService {
+
+    @Override
+    public MqCameraLevel getByCameraId(Long cameraId) {
+        LambdaQueryWrapper<MqCameraLevel> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(MqCameraLevel::getCameraId,cameraId);
+        return this.getOne(wrapper);
+    }
+
+    @Override
+    public void saveEntity(Long cameraId, Integer configId) {
+        MqCameraLevel cameraLevel = new MqCameraLevel();
+        cameraLevel.setCameraId(cameraId);
+        cameraLevel.setQueueConfigId(configId);
+        this.save(cameraLevel);
+    }
+
+    @Override
+    public void updateLevelById(Integer id, Integer configId) {
+        LambdaUpdateWrapper<MqCameraLevel> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(MqCameraLevel::getId,id);
+        wrapper.set(MqCameraLevel::getQueueConfigId,configId);
+        this.update(wrapper);
+    }
+}

+ 45 - 0
src/main/java/com/fdkankan/manage/service/impl/MqNumLevelServiceImpl.java

@@ -0,0 +1,45 @@
+package com.fdkankan.manage.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.manage.entity.MqCameraLevel;
+import com.fdkankan.manage.entity.MqNumLevel;
+import com.fdkankan.manage.mapper.IMqNumLevelMapper;
+import com.fdkankan.manage.service.IMqNumLevelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2024-04-17
+ */
+@Service
+public class MqNumLevelServiceImpl extends ServiceImpl<IMqNumLevelMapper, MqNumLevel> implements IMqNumLevelService {
+
+    @Override
+    public MqNumLevel getByNum(String num) {
+        LambdaQueryWrapper<MqNumLevel> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(MqNumLevel::getNum,num);
+        return this.getOne(wrapper);
+    }
+
+    @Override
+    public void saveEntity(String num, Integer configId) {
+        MqNumLevel mqNumLevel = new MqNumLevel();
+        mqNumLevel.setNum(num);
+        mqNumLevel.setQueueConfigId(configId);
+        this.save(mqNumLevel);
+    }
+
+    @Override
+    public void updateLevelById(Integer id, Integer configId) {
+        LambdaUpdateWrapper<MqNumLevel> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(MqNumLevel::getId,id);
+        wrapper.set(MqNumLevel::getQueueConfigId,configId);
+        this.update(wrapper);
+    }
+}

+ 31 - 0
src/main/java/com/fdkankan/manage/test/TestController.java

@@ -1,4 +1,5 @@
 package com.fdkankan.manage.test;
 package com.fdkankan.manage.test;
+import com.fdkankan.manage.vo.request.ModelingLevelParam;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
@@ -18,6 +19,7 @@ import com.fdkankan.manage.util.ExcelUtil;
 import com.fdkankan.manage.util.RsaUtils;
 import com.fdkankan.manage.util.RsaUtils;
 import com.fdkankan.manage.vo.request.SceneParam;
 import com.fdkankan.manage.vo.request.SceneParam;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
@@ -224,4 +226,33 @@ public class TestController {
         return ResultData.ok();
         return ResultData.ok();
     }
     }
 
 
+    @Autowired
+    IMqCameraLevelService mqCameraLevelService;
+    @Autowired
+    IMqNumLevelService mqNumLevelService;
+
+    @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();
+    }
 }
 }

+ 10 - 0
src/main/java/com/fdkankan/manage/vo/request/ModelingLevelParam.java

@@ -0,0 +1,10 @@
+package com.fdkankan.manage.vo.request;
+
+import lombok.Data;
+
+@Data
+public class ModelingLevelParam {
+    private Long cameraId;
+    private String num;
+    private Integer configId;
+}

+ 5 - 0
src/main/resources/mapper/manage/MqCameraLevelMapper.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.IMqCameraLevelMapper">
+
+</mapper>

+ 5 - 0
src/main/resources/mapper/manage/MqNumLevelMapper.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.IMqNumLevelMapper">
+
+</mapper>