| | |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.gateway.data.BaseResp; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.protocol.ProtocolUtils; |
| | | import com.fzzy.protocol.fzzy.builder.GrainCommandBuilder; |
| | | import com.fzzy.protocol.fzzy.cmd.BaseRemoteImpl; |
| | | import com.fzzy.protocol.fzzy.data.SendMessage; |
| | |
| | | GatewayDevice device = reqData.getDevice(); |
| | | |
| | | //获取连接中的设备信息 |
| | | ApiCommonDevice apiCommonDevice = Constant.getCommonDeviceCache(device.getDeviceSn()); |
| | | ApiCommonDevice apiCommonDevice = Constant.getCommonDeviceCache(device.getIp()); |
| | | |
| | | if (null == apiCommonDevice) { |
| | | resp.setCode(500); |
| | |
| | | try { |
| | | |
| | | //Step 请求信息放入内存 |
| | | ServerUtils.addSyncReq2Map(device.getDepotId(), reqData); |
| | | ProtocolUtils.addSyncReq2Map(device.getDepotIdSys(), reqData); |
| | | |
| | | // Step1 生成粮情信息 |
| | | SendMessage message = GrainCommandBuilder.getInstance().buildMessage(device,apiCommonDevice); |
| | | // 发送命令 |
| | | InvokeResult result = send(device.getIp(), device.getPort(), message.getByteMsg()); |
| | | |
| | | log.error("平台------>>>>控制柜:粮情检测-{}", message); |
| | | log.error("平台------>>>>控制柜:发送粮情检测命令-{}", message); |
| | | |
| | | // 封装返回信息 |
| | | if (!InvokeResult.SUCCESS.getCode().equals(result.getCode())) { |
| | | log.error("平台------>>>>控制柜:粮情检测-失败{}", result.getMessage()); |
| | | log.error("平台------>>>>控制柜:发送粮情检测命令-失败{}", result.getMessage()); |
| | | resp.setCode(500); |
| | | resp.setMsg("平台------>>>>控制柜:粮情检测-失败:" + result.getMessage()); |
| | | resp.setMsg("平台------>>>>控制柜:发送粮情检测命令-失败:" + result.getMessage()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("粮情检测异常:{}", e); |
| | | resp.setCode(500); |
| | | resp.setMsg("粮情检测异常:" + e.getMessage()); |
| | | resp.setMsg("平台------>>>>控制柜:发送粮情检测命令:" + e.getMessage()); |
| | | return resp; |
| | | } |
| | | return resp; |