| | |
| | | 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.pushByMin(hexStr); |
| | | serverEngine.push(message.getIp(),message.getPort(),BytesUtil.hexStrToBytes(hexStr)); |
| | | } |
| | | |
| | | private void analysisGrain2(DeviceSer ser, IoMessage message, ExeRequest exeRequest, DepotConf depotConf, DicSysConf sysConf, String batchId, String grainStr) { |
| | |
| | | th.setCompanyId(ContextUtil.getDefaultCompanyId()); |
| | | String data = message.getContent(); |
| | | String houseNo = data.substring(0, 2); |
| | | int depotId = BytesUtil.hexToInt(houseNo); |
| | | String t = data.substring(4, 8); |
| | | String h = data.substring(8, 12); |
| | | double temp, humy; |
| | |
| | | |
| | | 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) { |
| | |
| | | } finally { |
| | | String hexStr = CommandBuild.getMsgTHReply(message.getAddr()); |
| | | log.info("平台--------->>>主机,返回仓温仓湿收到信息,报文={}", hexStr); |
| | | serverEngine.pushByMin(hexStr); |
| | | serverEngine.push(message.getIp(),message.getPort(),BytesUtil.hexStrToBytes(hexStr)); |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | } |