| | |
| | | } |
| | | |
| | | @Override |
| | | public BaseResp syncGrainTh(BaseReqData reqData) { |
| | | |
| | | BaseResp resp = new BaseResp(); |
| | | |
| | | GatewayDevice device = reqData.getDevice(); |
| | | |
| | | //获取连接中的设备信息 |
| | | ApiCommonDevice apiCommonDevice = Constant.getCommonDeviceCache(device.getDeviceSn()); |
| | | |
| | | if (null == apiCommonDevice) { |
| | | resp.setCode(500); |
| | | resp.setMsg("系统未获取到下行连接设备信息,无法执行"); |
| | | log.error("----------------系统未获取到下行连接设备信息,无法执行---------"); |
| | | return resp; |
| | | } |
| | | |
| | | if (Constant.YN_N.equals(apiCommonDevice.getStatus())) { |
| | | resp.setCode(500); |
| | | resp.setMsg("下行设备不在线---无法执行----" + device.getDeviceName()); |
| | | log.error("下行设备不在线---无法执行----" + device.getDeviceName()); |
| | | return resp; |
| | | } |
| | | |
| | | device.setIp(apiCommonDevice.getIp()); |
| | | device.setPort(apiCommonDevice.getPort()); |
| | | |
| | | reqData.setDevice(device); |
| | | |
| | | try { |
| | | //生成温度命令 |
| | | Message message = CommandBuilder1128.getInstance().getInstance().buildMessage(reqData, apiCommonDevice); |
| | | |
| | | log.error("平台------>>>>控制柜:发送温湿度检测命令-{}", message); |
| | | // 发送命令 |
| | | InvokeResult result = ZldzServerEngine.push(apiCommonDevice.getIp(), apiCommonDevice.getPort(), message.getByteMsg()); |
| | | |
| | | // 封装返回信息 |
| | | if (!InvokeResult.SUCCESS.getCode().equals(result.getCode())) { |
| | | log.error("平台------>>>>控制柜:发送温湿度检测命令-失败{}", result.getMessage()); |
| | | resp.setCode(500); |
| | | resp.setMsg("平台------>>>>控制柜:发送温湿度检测命令-失败:" + result.getMessage()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("温湿度检测异常:{}", e); |
| | | resp.setCode(500); |
| | | resp.setMsg("平台------>>>>控制柜:发送温湿度检测命令:" + e.getMessage()); |
| | | return resp; |
| | | } |
| | | |
| | | return resp; |
| | | } |
| | | |
| | | @Override |
| | | public BaseResp syncConf(BaseReqData reqData) { |
| | | BaseResp resp = new BaseResp(); |
| | | |
| | |
| | | request.setSerName(device.getDeviceName()); |
| | | |
| | | // Step1 生成命令 |
| | | Message message = CommandBuilder1116_1.getInstance().buildMessage(request,device); |
| | | Message message = CommandBuilder1116_1.getInstance().buildMessage(request, device); |
| | | // 发送命令 |
| | | InvokeResult result = ZldzServerEngine.push(device.getIp(), device.getPort(), message.getByteMsg()); |
| | | |
| | |
| | | |
| | | ApiCommonDevice commonDevice = Constant.getCommonDeviceCache(device.getDeviceSn()); |
| | | |
| | | if(null == commonDevice){ |
| | | if (null == commonDevice) { |
| | | resp.setCode(500); |
| | | resp.setMsg("系统未发现连接设备,取消执行"); |
| | | return resp; |
| | | } |
| | | |
| | | ZldzServerEngine.disconnect(commonDevice.getIp(),commonDevice.getPort()); |
| | | ZldzServerEngine.disconnect(commonDevice.getIp(), commonDevice.getPort()); |
| | | return resp; |
| | | } |
| | | |