| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | } |
| | | } |