vince
2024-03-01 f7178996ca77a1bccc941c0e7a73b36803e508cb
src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java
@@ -125,7 +125,7 @@
            //获取请求信息
            BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDepotIdSys());
            BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDeviceSn());
            if (null == reqData) {
                replayGrain(message);
                log.error("主机-------->>平台,解析粮情失败,未获取到粮情请求信息:" + message.getAddr());
@@ -350,18 +350,46 @@
        JSONObject properties = new JSONObject();
        properties.put("data", outPut);
        properties.put("timestamp", grain.getTimestamp());
        properties.put("timestamp", grain.getTimestamp());
        outPut.setDetectTime( grain.getTimestamp());
        String height = this.getCacheHeight(device);
        if (StringUtils.isEmpty(height)) height = "0.0";
        properties.put("liquidHeight", height);
        grain.setProperties(properties);
        outPut.setLiquidHeight(height);
        grain.setOutput(JSONObject.toJSONString(outPut));
        properties.put("output", outPut);
        GatewayDevice gatewayDeviceWeather = GatewayUtils.getCacheByDeviceTypeOne(GatewayDeviceType.TYPE_09.getCode());
        //系统气象站信息
        WeatherWebDto weather = WeatherWebDto.contextMap.get("default");
        //气象信息
        GrainWeather weatherStation = new GrainWeather();
        weatherStation.setMessageId(ScConstant.getMessageId());
        weatherStation.setMessgeId(weatherStation.getMessageId());
        if (null != gatewayDeviceWeather) {
            weatherStation.setId(gatewayDeviceWeather.getDeviceId());
        } else {
            weatherStation.setId(device.getDeviceId());
        }
        weatherStation.setAirPressure(weather.getPressure());
        weatherStation.setHumidity(weather.getHumidity());
        weatherStation.setPm(weather.getAir_pm25());
        weatherStation.setRadiation("0");
        weatherStation.setRainfallAmount(weather.getWea());
        weatherStation.setTemperature(weather.getTem());
        weatherStation.setWindDirection(weather.getWin());
        weatherStation.setWindPower(weather.getWin_meter());
        weatherStation.setWindSpeed(weather.getWin_speed());
        grain.setWeatherStation(JSONObject.toJSONString(weatherStation));
        //封装好的数据
        log.info("---油罐仓信息封装完成----开始执行推送");
        grain.setProperties(properties);
        reqData.setData(JSONObject.toJSONString(grain));
        doPushGrain(reqData);
@@ -375,8 +403,17 @@
     */
    private String getCacheHeight(GatewayDevice device) {
        //给其他软使用
        String key = RedisConst.KEY_DEPOT_HEIGHT + ":" + configData.getCompanyId() + "_" + device.getDepotIdSys();
        return (String) redisUtil.get(key);
        //igds:5012:DEPOT_HEIGHT:0134
        String key = "igds:"+ device.getOrgId() + ":"  + RedisConst.KEY_DEPOT_HEIGHT+ ":" + device.getDepotIdSys();
        com.ld.igds.grain.dto.GrainData ht = (com.ld.igds.grain.dto.GrainData) redisUtil.get(key);
        log.info("KEY="+key);
        if(ht!=null){
            log.info("VALUE="+ht.getOilHeight());
            return ht.getOilHeight() ;
        }else {
            return "0.0";
        }
    }