| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | import com.github.pagehelper.util.StringUtil; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A1Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A5Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.MainBoardDataTransparentReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonRequest; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.InvokeParam; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A1OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.param.MQTTTestPrarm; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/sendRRPC") |
| | | public ResponseVO<Object> sendRRPC(@RequestBody @Validated MQTTTestPrarm mqttTestPrarm) { |
| | | /** |
| | |
| | | param.setOperate("1001"); |
| | | param.setFrame(mqttTestPrarm.getFrameStr()); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(pole.getDeviceCode(), param); |
| | | if (commonFrame == null) { |
| | | throw new BusinessException("请æ±å¤±è´¥ï¼è¯·éæ°è¯·æ±"); |
| | | if (commonFrame == null || !commonFrame.isValidate()) { |
| | | throw new BusinessException("ååºæ°æ®æ ¡éªå¤±è´¥ï¼è¯·éæ°è¯·æ±æ°æ®ï¼"); |
| | | } |
| | | return ResponseUtil.success(commonFrame); |
| | | String value = commonFrame.getConnectType() + commonFrame.getFunctionCode() |
| | | + commonFrame.getOrderType() + commonFrame.getPayloadLength() |
| | | + commonFrame.getPayload() + commonFrame.getCrc32(); |
| | | Map map = new LinkedHashMap(); |
| | | map.put("frame", value); |
| | | return ResponseUtil.success(map); |
| | | } |
| | | |
| | | @PostMapping("/transparentFrame") |
| | | public ResponseVO<Object> transparentFrame(@RequestBody @Validated CommonRequest commonRequest) { |
| | | boolean isAscii = commonRequest.getAscii().equals(0) ? false : true; |
| | | Pole pole = SpringContextHolder.getBean(PoleService.class).getById(commonRequest.getPoleID()); |
| | | if (pole == null) { |
| | | throw new BusinessException("ç¯æä¸åå¨ï¼"); |
| | | } |
| | | if (StringUtil.isEmpty(pole.getDeviceCode())) { |
| | | throw new BusinessException("ç¯æMACä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | |
| | | MainBoardDataTransparentReqInnerFrame mainBoardDataTransparentReqInnerFrame = new MainBoardDataTransparentReqInnerFrame(commonRequest.getFrame(), isAscii); |
| | | A1Frame a1Frame = new A1Frame(A1OrderEnum.TRANSPARENT.getCode(), mainBoardDataTransparentReqInnerFrame); |
| | | System.out.println("a1Frame:" + a1Frame.getEncodeFrame()); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(pole.getDeviceCode(), a1Frame); |
| | | |
| | | if (null == commonFrame) { |
| | | throw new BusinessException("ä¸»æ¿æ ååº!"); |
| | | } |
| | | if (commonFrame == null || !commonFrame.isValidate()) { |
| | | throw new BusinessException("ååºæ°æ®æ ¡éªå¤±è´¥ï¼è¯·éæ°è¯·æ±æ°æ®ï¼"); |
| | | } |
| | | String value = commonFrame.getConnectType() + commonFrame.getFunctionCode() |
| | | + commonFrame.getOrderType() + commonFrame.getPayloadLength() |
| | | + commonFrame.getPayload() + commonFrame.getCrc32(); |
| | | Map map = new LinkedHashMap(); |
| | | map.put("frame", value); |
| | | map.put("data", HexUtil.decodeHexStr(commonFrame.getPayload())); |
| | | System.out.println(HexUtil.decodeHexStr(commonFrame.getPayload())); |
| | | |
| | | return ResponseUtil.success(map); |
| | | } |
| | | } |