| | |
| | | package com.fzzy.gateway.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.bstek.dorado.annotation.DataProvider; |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | |
| | | import com.fzzy.gateway.hx2023.websocket.WebSocketDeviceReport; |
| | | import com.fzzy.gateway.service.repository.GatewayDeviceRep; |
| | | |
| | | import com.fzzy.mqtt.MqttPublishService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.apache.commons.lang.StringUtils; |
| | |
| | | @Resource |
| | | private GatewayRemoteManager gatewayRemoteManager; |
| | | @Resource |
| | | private WebSocketDeviceReport webSocketDeviceReport; |
| | | private MqttPublishService mqttPublishService; |
| | | /** |
| | | * gatewayDeviceService#listAll |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String ajaxTestWeight(Map<String, Object> parameter) { |
| | | double weigh = (double) parameter.get("weight"); |
| | | public String ajaxTestWeight() { |
| | | //double weigh = (double) parameter.get("weight"); |
| | | double weigh = Double.parseDouble("3500.0"); |
| | | List<GatewayDevice> devices = listAll(); |
| | | if(devices == null || devices.size()<= 0){ |
| | | return "没有设备"; |
| | |
| | | if(weights == null || weights.size()<= 0){ |
| | | return "没有获取到地磅设备"; |
| | | } |
| | | String topic = "/device/hx-weigh-big-01/91511424746940066Y001_91511424746940066Y0010000_002_004_002_001/message/property/report"; |
| | | |
| | | for (GatewayDevice device: weights) { |
| | | |
| | | WebSocketPacket packet = new WebSocketPacket(); |
| | |
| | | |
| | | packet.setTimestamp(System.currentTimeMillis()); |
| | | |
| | | |
| | | webSocketDeviceReport.sendByPacket(packet); |
| | | topic = "/device/hx-weigh-big-01/"+device.getDeviceId()+"/message/property/report"; |
| | | mqttPublishService.publishMsg(topic, JSON.toJSONString(packet)); |
| | | } |
| | | return "SUCCESS"; |
| | | } |