| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiCommonDevice; |
| | | import com.fzzy.api.data.DepotType; |
| | | import com.fzzy.api.data.GatewayDeviceType; |
| | | import com.fzzy.api.utils.BytesUtil; |
| | | import com.fzzy.api.utils.NumberUtil; |
| | |
| | | private void analysisGrain(IoMessage message) { |
| | | try { |
| | | //根据分机SN获取设备配置信息 |
| | | GatewayDevice gatewayDevice = GatewayUtils.getCacheByDeviceSn(message.getAddr()); |
| | | GatewayDevice gatewayDevice = BhznGrainV0ServerUtils.contextOrder; |
| | | if (null == gatewayDevice) { |
| | | replayGrain(message); |
| | | log.error("主机-------->>平台,解析粮情失败,未获取到系统设备配置信息:" + message.getAddr()); |
| | | return; |
| | | } |
| | | //根据分机地址获取分机信息 |
| | | ApiCommonDevice commonDevice = Constant.getCommonDeviceCache(message.getIp()); |
| | | if (commonDevice == null) { |
| | | replayGrain(message); |
| | | log.error("主机-------->>平台,解析粮情失败,未获取到系统粮情主机配置:" + message.getAddr()); |
| | | return; |
| | | } |
| | | // ApiCommonDevice commonDevice = Constant.getCommonDeviceCache(message.getIp()); |
| | | // if (commonDevice == null) { |
| | | // replayGrain(message); |
| | | // log.error("主机-------->>平台,解析粮情失败,未获取到系统粮情主机配置:" + message.getAddr()); |
| | | // return; |
| | | // } |
| | | |
| | | //获取请求信息 |
| | | BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDepotIdSys()); |
| | |
| | | String hexStr = CommandBuild.getMsgGrainReply(message.getAddr()); |
| | | log.info("平台--------->>>主机,返回粮情报文收到信息,报文={}", hexStr); |
| | | |
| | | BhznGrainV0ServerEngine.push(message.getIp(), message.getPort(), BytesUtil.hexStrToBytes(hexStr)); |
| | | BhznGrainV0ServerEngine.pushByMin(hexStr); |
| | | } |
| | | |
| | | /** |
| | |
| | | contextMapGrain.put(key, null); |
| | | |
| | | |
| | | if (cableData.isCir()) { |
| | | |
| | | if(DepotType.TYPE_03.getCode().equals(device.getDepotType())){ |
| | | //筒仓 |
| | | analysisAndPush3(temps, reqData, thDto, cableData); |
| | | }else if(DepotType.TYPE_02.getCode().equals(device.getDepotType())){ |
| | | analysisAndPush2(temps, reqData, thDto, cableData); |
| | | } else { |
| | | }else if(DepotType.TYPE_04.getCode().equals(device.getDepotType())){ |
| | | analysisAndPush2(temps, reqData, thDto, cableData); |
| | | }else { |
| | | //平房仓 |
| | | analysisAndPush1(temps, reqData, thDto, cableData); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 筒仓解析,解析第二步,解析到坐标数据 |
| | | * 筒仓,解析第二步,解析到坐标数据 |
| | | * @param temps |
| | | * @param reqData |
| | | * @param thDto |
| | | * @param cableData |
| | | */ |
| | | private void analysisAndPush2(List<Double> temps, BaseReqData reqData, THDto thDto, GrainCableData cableData) { |
| | | //TODO |
| | | log.info("-------------------------暂未实现----------------"); |
| | | } |
| | | |
| | | /** |
| | | * 油罐仓,解析第二步,解析到坐标数据 |
| | | * |
| | | * @param temps |
| | | * @throws Exception |
| | | */ |
| | | private void analysisAndPush2(List<Double> temps, BaseReqData reqData, THDto thDto, GrainCableData cableData) { |
| | | private void analysisAndPush3(List<Double> temps, BaseReqData reqData, THDto thDto, GrainCableData cableData) { |
| | | |
| | | GatewayDevice device = reqData.getDevice(); |
| | | |
| | |
| | | |
| | | |
| | | JSONObject properties = new JSONObject(); |
| | | properties.put("data", JSONObject.toJSONString(outPut)); |
| | | properties.put("data", outPut); |
| | | properties.put("timestamp", grain.getTimestamp()); |
| | | |
| | | String height = this.getCacheHeight(device); |
| | | if (StringUtils.isEmpty(height)) height = "0.0"; |
| | | properties.put("liquidHeight", height); |
| | | |
| | | grain.setProperties(properties.toJSONString()); |
| | | grain.setProperties(properties); |
| | | |
| | | //封装好的数据 |
| | | log.info("---浅圆仓封装完成----开始执行推送"); |
| | |
| | | } finally { |
| | | String hexStr = CommandBuild.getMsgTHReply(message.getAddr()); |
| | | log.info("平台--------->>>主机,返回仓温仓湿收到信息,报文={}", hexStr); |
| | | BhznGrainV0ServerEngine.push(message.getIp(), message.getPort(), BytesUtil.hexStrToBytes(hexStr)); |
| | | BhznGrainV0ServerEngine.pushByMin(hexStr); |
| | | } |
| | | } |
| | | |