2021与蓝度共同重构项目,服务端
LHN
2022-10-19 08429736fe89c3c3a988d794f7cb6c0170d18afa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.sandu.ximon.admin.controller;
 
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.util.StringUtil;
import com.sandu.common.domain.CommonPage;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.util.ResponseUtil;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.InvokeParam;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.param.MonitorParam;
import com.sandu.ximon.admin.security.PermissionConfig;
import com.sandu.ximon.admin.service.PoleService;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.enums.MenuEnum;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
/**
 * MQTT测试
 *
 * @author ZZQ
 * @date 2022/10/19 15:49
 */
@RestController
@AllArgsConstructor
@RequestMapping("/v1/admin/mqtt")
public class MQTTTestController {
    private PermissionConfig permissionConfig;
 
    /**
     * 模糊查询
     *
     * @return
     */
    @GetMapping("/sendRRPC")
    public ResponseVO<Object> listMonitorByKeyword(@RequestParam(value = "poleId", required = false) Long poleId,
                                                   @RequestParam(value = "frameStr", required = false) String frameStr) {
        if (poleId == null) {
            throw new BusinessException("灯杆ID不能为空!");
        }
 
        if (StringUtil.isEmpty(frameStr)) {
            throw new BusinessException("请求帧数据不能为空!");
        }
        if (!permissionConfig.check(MenuEnum.MQTT_TEST.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
 
 
        Pole pole = SpringContextHolder.getBean(PoleService.class).getById(poleId);
        if (pole == null) {
            throw new BusinessException("灯杆不存在!");
        }
 
        if (StringUtil.isEmpty(pole.getDeviceCode())) {
            throw new BusinessException("灯杆MAC不能为空!");
        }
 
        InvokeParam param = new InvokeParam();
        param.setOperate("1001");
        param.setFrame(frameStr);
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(pole.getDeviceCode(), param);
        if (commonFrame == null) {
            throw new BusinessException("请求失败,请重新请求");
        }
        return ResponseUtil.success(commonFrame);
    }
}