| | |
| | | //消息 ID |
| | | private String messageId; |
| | | |
| | | private String messgeId; |
| | | |
| | | //设备编码 |
| | | private String deviceID; |
| | | |
| | |
| | | //检测时间-格式:yyyy-MM-dd HH:mm:ss |
| | | private String collectTime; |
| | | |
| | | private int minX = 0; |
| | | private String minX = "0"; |
| | | |
| | | private int minY = 0; |
| | | private String minY = "0"; |
| | | |
| | | private int minZ = 0; |
| | | private String minZ = "0"; |
| | | |
| | | private int maxX = 0; |
| | | private String maxX = "0"; |
| | | |
| | | private int maxY = 0; |
| | | private String maxY = "0"; |
| | | |
| | | private int maxZ = 0; |
| | | private String maxZ = "0"; |
| | | |
| | | //模块识别码-常量,固定传 apiTemperature |
| | | private String apISource = "apiTemperature"; |
| | |
| | | private String position; |
| | | |
| | | //该温度点所在的列,平方仓、地下仓必填 |
| | | private int linex; |
| | | private String linex; |
| | | |
| | | //该温度点所在的行,平方仓、地下仓必填 |
| | | private int rowy; |
| | | private String rowy; |
| | | |
| | | //浅圆仓、筒仓必填,示例:{\"totalCircle\":3,\"smallCircle\":\"4,10,16\"},totalCircle:总圈数,smallCircle:每圈有几根缆 |
| | | private int total_circle; |
| | | private String total_circle; |
| | | |
| | | |
| | | //具体圈数--浅圆仓、筒仓必填 |
| | | private int circle; |
| | | private String circle; |
| | | |
| | | public KafkaGrainDataDetail() { |
| | | } |
| | | |
| | | public KafkaGrainDataDetail(String cableNum, String layerNumber, String temperature, String position, int linex, int rowy, int total_circle, int circle) { |
| | | public KafkaGrainDataDetail(String cableNum, String layerNumber, String temperature, String position, String linex, String rowy, String total_circle, String circle) { |
| | | this.cableNum = cableNum; |
| | | this.layerNumber = layerNumber; |
| | | this.temperature = temperature; |
| | |
| | | this.circle = circle; |
| | | } |
| | | |
| | | public KafkaGrainDataDetail(String cableNum, String layerNumber, String temperature, String position, int linex, int rowy) { |
| | | public KafkaGrainDataDetail(String cableNum, String layerNumber, String temperature, String position, String linex, String rowy) { |
| | | this.cableNum = cableNum; |
| | | this.layerNumber = layerNumber; |
| | | this.temperature = temperature; |
| | |
| | | private String position; |
| | | |
| | | //该温度点所在的列,平方仓、地下仓必填 |
| | | private int linex; |
| | | private String linex; |
| | | |
| | | //该温度点所在的行,平方仓、地下仓必填 |
| | | private int rowy; |
| | | private String rowy; |
| | | |
| | | //浅圆仓、筒仓必填,示例:{\"totalCircle\":3,\"smallCircle\":\"4,10,16\"},totalCircle:总圈数,smallCircle:每圈有几根缆 |
| | | // private int total_circle; |
| | | private String total_circle; |
| | | |
| | | |
| | | //具体圈数--浅圆仓、筒仓必填 |
| | | // private int circle; |
| | | private String circle; |
| | | |
| | | public KafkaGrainDataDetail1() { |
| | | } |
| | | |
| | | public KafkaGrainDataDetail1(String cableNum, String layerNumber, String temperature, String position, int linex, int rowy) { |
| | | public KafkaGrainDataDetail1(String cableNum, String layerNumber, String temperature, String position, String linex, String rowy) { |
| | | this.cableNum = cableNum; |
| | | this.layerNumber = layerNumber; |
| | | this.temperature = temperature; |
| | |
| | | |
| | | |
| | | String strData = JSONObject.toJSONString(data); |
| | | log.debug("----推送粮情信息到云端---{}", strData); |
| | | //log.debug("----推送粮情信息到云端---{}", strData); |
| | | |
| | | //推送信息 |
| | | kafkaTemplate.send("TOPIC_ZLJ_GRAIN_TEMPERATURE", strData).addCallback(success -> { |
| | |
| | | // 消息在分区内的offset |
| | | long offset = success.getRecordMetadata().offset(); |
| | | |
| | | log.info("粮情推送成功:{}-{}-{}-{}", topic, partition, offset, data.getDeviceID()); |
| | | log.info("---粮情-->>云端成功:{}-{}-{}-{}", topic, partition, offset, strData); |
| | | }, failure -> { |
| | | log.info("粮情推送失败:{}-{}", data.getDeviceID(), failure.getMessage()); |
| | | log.info("---粮情-->>云端失败:{}-{}", data.getDeviceID(), failure.getMessage()); |
| | | }); |
| | | |
| | | return "SUCCESS"; |
| | |
| | | KafaGrainData result = new KafaGrainData(); |
| | | |
| | | result.setMessageId(ScConstant.getMessageId()); |
| | | result.setMessgeId(result.getMessageId()); |
| | | result.setDeviceID(device.getDeviceId()); |
| | | result.setAvgTemperature(lastData.getTempAve() + ""); |
| | | result.setMinTemperature(lastData.getTempMin() + ""); |
| | |
| | | |
| | | //判断最大 |
| | | if (curTemp.equals(result.getMaxTemperature())) { |
| | | result.setMaxX(x); |
| | | result.setMaxY(y); |
| | | result.setMaxZ(position); |
| | | result.setMaxX(x+""); |
| | | result.setMaxY(y+""); |
| | | result.setMaxZ(position+""); |
| | | } |
| | | |
| | | |
| | | //判断最小 |
| | | if (curTemp.equals(result.getMinTemperature())) { |
| | | result.setMinX(x); |
| | | result.setMinY(y); |
| | | result.setMinZ(position); |
| | | result.setMinX(x+""); |
| | | result.setMinY(y+""); |
| | | result.setMinZ(position+""); |
| | | } |
| | | |
| | | temperature.add(new KafkaGrainDataDetail1(cableNum + "", z + "", curTemp, position + "", x, y)); |
| | | temperature.add(new KafkaGrainDataDetail1(cableNum + "", z + "", curTemp, position + "", x+"", y+"")); |
| | | } |
| | | |
| | | //粮温信息 |
| | |
| | | List<KafkaGrainTH> temperatureAndhumidity = new ArrayList<>(); |
| | | temperatureAndhumidity.add(grainTH); |
| | | |
| | | // trhInfo.setTemperatureAndhumidity(temperatureAndhumidity); |
| | | trhInfo.put("temperatureAndhumidity",temperatureAndhumidity); |
| | | //trhInfo.put("temperatureAndhumidity",grainTH); |
| | | |
| | | JSONObject params = new JSONObject(); |
| | | params.put("TRHInfo", trhInfo); |