| | |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.gateway.hx2023.ScConstant; |
| | | import com.fzzy.gateway.hx2023.data.*; |
| | | import com.fzzy.protocol.ConstantProtocol; |
| | | import com.fzzy.protocol.ProtocolUtils; |
| | | import com.fzzy.protocol.bhzn.cmd.CommandBuild; |
| | | import com.fzzy.protocol.bhzn.cmd.ReMessageBuilder; |
| | | import com.fzzy.protocol.bhzn.data.IoMessage; |
| | | import com.fzzy.protocol.bhzn.data.THDto; |
| | | import com.fzzy.protocol.data.THDto; |
| | | import com.fzzy.protocol.bhzn.server.BhznGrainV2ServerEngine; |
| | | import com.fzzy.protocol.bhzn.server.BhznGrainV2ServerUtils; |
| | | import com.fzzy.protocol.fzzy.server.ServerUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | private void analysisGrain(IoMessage message) { |
| | | try { |
| | | |
| | | //根据分机SN获取设备配置信息 |
| | | GatewayDevice gatewayDevice = GatewayUtils.getCacheByDeviceSn(message.getAddr()); |
| | | if (null == gatewayDevice) { |
| | | replayGrain(message); |
| | | log.error("主机-------->>平台,解析粮情失败,未获取到系统设备配置信息:" + message.getAddr()); |
| | | return; |
| | | } |
| | | //根据分机地址获取分机信息 |
| | | ApiCommonDevice commonDevice = Constant.getCommonDeviceCache(message.getAddr()); |
| | | ApiCommonDevice commonDevice = Constant.getCommonDeviceCache(message.getIp()); |
| | | if (commonDevice == null) { |
| | | replayGrain(message); |
| | | log.error("主机-------->>平台,解析粮情失败,未获取到系统粮情主机配置:" + message.getAddr()); |
| | | return; |
| | | } |
| | | |
| | | //根据分机SN获取设备配置信息 |
| | | GatewayDevice gatewayDevice = GatewayUtils.getCacheByDeviceSn(commonDevice.getSn()); |
| | | if (null == gatewayDevice) { |
| | | replayGrain(message); |
| | | log.error("主机-------->>平台,解析粮情失败,未获取到系统设备配置信息:" + message.getAddr()); |
| | | return; |
| | | } |
| | | |
| | | |
| | | //获取请求信息 |
| | | BaseReqData reqData = BhznGrainV2ServerUtils.getSyncReq(gatewayDevice.getDepotIdSys()); |
| | | BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDepotIdSys()); |
| | | if (null == reqData) { |
| | | replayGrain(message); |
| | | log.error("主机-------->>平台,解析粮情失败,未获取到粮情请求信息:" + message.getAddr()); |
| | |
| | | } |
| | | |
| | | private void analysisGrain2(IoMessage message, BaseReqData reqData, String grainStr) { |
| | | |
| | | GatewayDevice device = reqData.getDevice(); |
| | | // 获取完整的粮情包信息 |
| | | String[] attCable = device.getCableRule().split("-"); |
| | |
| | | temp = "0000"; |
| | | } |
| | | if (ReMessageBuilder.ERROR_TAG.equals(temp)) { |
| | | tempValue = ConstantProtocol.ERROR_TEMP; |
| | | tempValue = ProtocolUtils.ERROR_TEMP; |
| | | } else { |
| | | tempValue = BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) / 10.0; |
| | | } |
| | | // 故障值处理 |
| | | if (tempValue >= ReMessageBuilder.FAULT_CHECK_TAG) { |
| | | tempValue = ConstantProtocol.FAULT_TEMP; |
| | | tempValue = ProtocolUtils.FAULT_TEMP; |
| | | } |
| | | temps.add(tempValue); |
| | | } |
| | |
| | | |
| | | THDto thDto = this.getTH(message); |
| | | if (null != thDto) { |
| | | log.debug("-------THDto--={}", thDto); |
| | | log.info("-------THDto--={}", thDto); |
| | | } |
| | | //清空 |
| | | String key = "GRAIN_" + message.getAddr(); |
| | |
| | | outPut.setAvgTemperature(NumberUtil.keepPrecision((sumT / sumNum), 1) + ""); |
| | | outPut.setMinTemperature(min + ""); |
| | | outPut.setMaxTemperature(min + ""); |
| | | List<GrainTH> ths = new ArrayList<>(); |
| | | |
| | | ths.add(new GrainTH(thDto.getTempIn()!=null?thDto.getTempIn()+"":"",thDto.getHumidityIn()!=null?thDto.getHumidityIn()+"":"","1")); |
| | | outPut.setTemperatureAndhumidity(ths); |
| | | grain.setOutput(JSONObject.toJSONString(outPut)); |
| | | |
| | | GatewayDevice gatewayDeviceWeather = GatewayUtils.getCacheByDeviceTypeOne(GatewayDeviceType.TYPE_09.getCode()); |
| | |
| | | try { |
| | | THDto th = new THDto(); |
| | | String data = message.getContent(); |
| | | String houseNo = data.substring(0, 4); |
| | | int depotId = BytesUtil.hexToInt(BytesUtil.tran_LH(houseNo)); |
| | | String houseNo = data.substring(0, 2); |
| | | int depotId = BytesUtil.hexToInt(houseNo); |
| | | String t = data.substring(4, 8); |
| | | String h = data.substring(8, 12); |
| | | double humy; |