| | |
| | | import com.fzzy.api.utils.SpringUtil; |
| | | import com.fzzy.gateway.GatewayUtils; |
| | | import com.fzzy.gateway.api.GatewayRemoteManager; |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.ld.io.api.IoMsgConsumer; |
| | | import com.ld.io.api.IoSession; |
| | |
| | | |
| | | private long timeTag = 0; |
| | | |
| | | private GatewayRemoteManager reportService; |
| | | private GatewayRemoteManager gatewayRemoteManager; |
| | | |
| | | @Override |
| | | public void consume(IoSession session, byte[] bytes) { |
| | |
| | | */ |
| | | public void analysisInfo(String ip, Integer port, byte[] bytes) { |
| | | String strMsg = BytesUtil.bytesToString(bytes); |
| | | //log.debug("开始解析地磅返回信息=" + strMsg); |
| | | |
| | | if (strMsg.length() < 22) { |
| | | return; |
| | | } |
| | |
| | | //最终重量结果 |
| | | double weigh = Double.valueOf(w) / d; |
| | | |
| | | |
| | | log.debug("WEIGHT-MESSAGE=" + strMsg); |
| | | log.debug("----------地磅称重数值解析------{}", weigh); |
| | | |
| | | //当前地磅协议不支持传递SN,使用局域网IP作为SN |
| | | String sn = ip; |
| | | |
| | | |
| | | //根据信息获取设备 |
| | | GatewayDevice device = GatewayUtils.getCacheByDeviceSn(sn); |
| | |
| | | } |
| | | |
| | | //直接调用实现类,更多实现类单独调用 |
| | | if (null == reportService) { |
| | | reportService = SpringUtil.getBean(GatewayRemoteManager.class); |
| | | if (null == gatewayRemoteManager) { |
| | | gatewayRemoteManager = SpringUtil.getBean(GatewayRemoteManager.class); |
| | | } |
| | | |
| | | reportService.getDeviceReportService(device.getPushProtocol()).report2GatewayBySn(weigh, device); |
| | | //数据封装推送 |
| | | BaseReqData reqData = new BaseReqData(); |
| | | reqData.setDevice(device); |
| | | reqData.setDeviceId(device.getDeviceId()); |
| | | reqData.setProductId(device.getProductId()); |
| | | reqData.setDeviceName(device.getDeviceName()); |
| | | reqData.setWeight(weigh); |
| | | |
| | | if (weigh > 0) { |
| | | gatewayRemoteManager.getDeviceReportService(device.getPushProtocol()).reportWeightData(reqData); |
| | | } |
| | | } |
| | | |
| | | /** |