| | |
| | | ser.setPort(message.getPort()); |
| | | ser.setStatus(Constant.YN_Y); |
| | | coreSerService.updateByData(ser); |
| | | log.info("主机------->>平台:注册成功,分机信息={}", ser); |
| | | } |
| | | return; |
| | | } |
| | |
| | | |
| | | //如果当前包的数据个数大于等于当前仓库的配置点位则表示单包返回 |
| | | if (curPoint >= sumPoint) { |
| | | |
| | | log.info("分机------>>>平台:粮情数据单包=" + grainHex); |
| | | //返回粮情接收信息 |
| | | replayGrain(message); |
| | | |
| | |
| | | if (grainHex.length() >= sumPoint * 4) { |
| | | //返回粮情接收信息 |
| | | replayGrain(message); |
| | | |
| | | log.info("分机------>>>平台:粮情数据多包,完整数据=" + grainHex); |
| | | analysisGrain2(ser, message, exeRequest, depotConf, sysConf, batchId, grainHex); |
| | | return; |
| | | |
| | | } else { |
| | | log.info("分机------>>>平台:将第一包数据存入内存=" + grainHex); |
| | | contextMapGrain.put(key, grainHex); |
| | | replayGrain(message); |
| | | } |
| | |
| | | * |
| | | * @param message |
| | | */ |
| | | private void replayGrain(IoMessage message) { |
| | | private void replayGrain(IoMessage message) throws InterruptedException { |
| | | Thread.sleep(50); |
| | | String hexStr = CommandBuild.getMsgGrainReply(message.getAddr()); |
| | | log.info("平台--------->>>主机,返回粮情报文收到信息,报文={}", hexStr); |
| | | serverEngine.push(message.getIp(),message.getPort(),BytesUtil.hexStrToBytes(hexStr)); |
| | |
| | | try { |
| | | THDto th = new THDto(); |
| | | th.setCompanyId(ContextUtil.getDefaultCompanyId()); |
| | | |
| | | String data = message.getContent(); |
| | | String houseNo = data.substring(0, 2); |
| | | String houseNo = data.substring(0, 4); |
| | | int depotId = BytesUtil.hexToInt(BytesUtil.tran_LH(houseNo)); |
| | | String t = data.substring(4, 8); |
| | | String h = data.substring(8, 12); |
| | | double temp, humy; |
| | | double humy; |
| | | String temp; |
| | | int symbol = 0; //符号位 |
| | | double tempValue; |
| | | if (ReMessageBuilder.ERROR_TAG.equals(t)) { |
| | | temp = 0.0; |
| | | temp = "0000"; |
| | | } else { |
| | | temp = (double) BytesUtil.hexToBigInt(BytesUtil.tran_LH(t)) / 10; |
| | | temp = BytesUtil.tran_LH(t); |
| | | } |
| | | temp = BytesUtil.hexString2binaryString(temp, 16); |
| | | |
| | | //符号位 |
| | | symbol = Integer.valueOf(temp.substring(0, 1)); |
| | | //获取温度值 |
| | | tempValue = BytesUtil.biannary2Decimal(temp.substring(6))/10; |
| | | //若为负,则补码:取反加1 |
| | | if (symbol == 1) { |
| | | tempValue = 0.0 - BytesUtil.twoToString(temp)/10; |
| | | } |
| | | th.setTempIn(tempValue); |
| | | if (ReMessageBuilder.ERROR_TAG.equals(h)) { |
| | | humy = 0.0; |
| | | } else { |
| | | humy = (double) BytesUtil.hexToBigInt(BytesUtil.tran_LH(h)) / 10; |
| | | } |
| | | |
| | | th.setTempIn(temp); |
| | | th.setHumidityIn(humy); |
| | | log.info("主机--------->>>平台,解析仓温仓湿信息,仓库={},结果={}", houseNo, th.toString()); |
| | | log.info("主机--------->>>平台,解析仓温仓湿信息,仓库={},结果={}", depotId, th.toString()); |
| | | |
| | | String key = "TH_" + houseNo; |
| | | String key = "TH_" + depotId; |
| | | contextMapTH.put(key, th); |
| | | |
| | | } catch (Exception e) { |
| | |
| | | private THDto getTH(IoMessage message) { |
| | | String data = message.getContent(); |
| | | String houseNo = data.substring(0, 2); |
| | | |
| | | String key = "TH_" + houseNo; |
| | | Integer depotId = BytesUtil.hexToInt(houseNo); |
| | | String key = "TH_" + depotId; |
| | | |
| | | return contextMapTH.get(key); |
| | | } |