| | |
| | | import com.fzzy.gateway.data.BaseResp; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.protocol.ProtocolUtils; |
| | | import com.fzzy.protocol.bhzn.cmd.CommandBuild; |
| | | import com.fzzy.protocol.bhzn.server.BhznGrainV2ServerEngine; |
| | | import com.fzzy.protocol.bhzn.v0.cmd.CommandBuild; |
| | | import com.fzzy.protocol.bhzn.v0.server.BhznGrainV0ServerEngine; |
| | | import com.fzzy.protocol.bhzn.v0.server.BhznGrainV0ServerUtils; |
| | | import com.ld.io.api.InvokeResult; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | BaseResp resp = new BaseResp(); |
| | | |
| | | GatewayDevice device = reqData.getDevice(); |
| | | |
| | | BhznGrainV0ServerUtils.contextOrder = device; |
| | | //获取连接中的设备信息 |
| | | ApiCommonDevice apiCommonDevice = Constant.getCommonDeviceCache(device.getIp()); |
| | | // ApiCommonDevice apiCommonDevice = Constant.getCommonDeviceCacheBySn(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; |
| | | // } |
| | | |
| | | 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()); |
| | | // device.setIp(apiCommonDevice.getIp()); |
| | | // device.setPort(apiCommonDevice.getPort()); |
| | | |
| | | reqData.setDevice(device); |
| | | |
| | |
| | | // 生成粮情信息 |
| | | String hexStr = CommandBuild.getInstance().getMsgCheck(device.getDeviceSn(), device.getDepotIdSys()); |
| | | // 发送命令 |
| | | InvokeResult message = BhznGrainV2ServerEngine.push(device.getIp(), device.getPort(), BytesUtil.hexStrToBytes(hexStr)); |
| | | InvokeResult message = BhznGrainV0ServerEngine.pushByMin(hexStr); |
| | | |
| | | log.error("平台------>>>>控制柜:发送粮情检测命令-{}", message); |
| | | |