| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang.math.RandomUtils; |
| | | import org.apache.commons.lang.time.DateFormatUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.domain.Sort; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * gatewayDeviceService#ajaxTestWeight |
| | | * 地磅推送测试 |
| | |
| | | */ |
| | | @Expose |
| | | public String ajaxTestWeight() { |
| | | //double weigh = (double) parameter.get("weight"); |
| | | double weigh = Double.parseDouble("3500.0"); |
| | | //double weigh = (double) parameter.getWeight(); |
| | | double weigh = Math.random() * (35000 - 16000 + 1) + 16000; |
| | | List<GatewayDevice> devices = listAll(); |
| | | if(devices == null || devices.size()<= 0){ |
| | | return "没有设备"; |
| | |
| | | |
| | | packet.setTimestamp(System.currentTimeMillis()); |
| | | |
| | | topic = "/device/hx-weigh-big-01/"+device.getDeviceId()+"/message/property/report"; |
| | | topic = "/device/"+header.getProductId()+"/"+device.getDeviceId()+"/message/property/report"; |
| | | mqttPublishService.publishMsg(topic, JSON.toJSONString(packet)); |
| | | } |
| | | return "SUCCESS"; |
| | | } |
| | | |
| | | /** |
| | | * gatewayDeviceService#ajaxTestLpr |
| | | * 地磅推送测试 |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String ajaxTestLpr() { |
| | | //String carNumber = parameter.getCarNumber(); |
| | | String carNumber = "川A12345"; |
| | | List<GatewayDevice> devices = listAll(); |
| | | if(devices == null || devices.size()<= 0){ |
| | | return "没有设备"; |
| | | } |
| | | List<GatewayDevice> weights = devices.stream().filter(s ->(GatewayDeviceType.TYPE_02.getCode().equals(s.getType()))).collect(Collectors.toList()); |
| | | 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(); |
| | | |
| | | //productId的值在webSocket执行发送方法中补充 |
| | | WebSocketPacketHeader header = new WebSocketPacketHeader(); |
| | | header.setDeviceName(device.getDeviceName()); |
| | | header.setProductId("hx-catch-01"); |
| | | //header.set |
| | | packet.setHeaders(header); |
| | | packet.setMessageType(ScConstant.MESSAGE_TYPE_REPORT_PROPERTY); |
| | | packet.setDeviceId(device.getDeviceId()); |
| | | packet.setMessageId(System.currentTimeMillis() + ""); |
| | | //设置信息主体 |
| | | LprData lpr = new LprData(); |
| | | lpr.setDeviceId(device.getDeviceId()); |
| | | lpr.setCarNumber(carNumber); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("carNumber", carNumber); |
| | | jsonObject.put("position", "big"); |
| | | packet.setProperties(jsonObject); |
| | | |
| | | packet.setTimestamp(System.currentTimeMillis()); |
| | | |
| | | topic = "/device/"+header.getProductId()+"/"+device.getDeviceId()+"/message/property/report"; |
| | | mqttPublishService.publishMsg(topic, JSON.toJSONString(packet)); |
| | | } |
| | | return "SUCCESS"; |
| | | } |
| | | |
| | | /** |
| | | * gatewayDeviceService#ajaxTestGrain |
| | |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String ajaxTestGrain(Map<String, Object> parameter) { |
| | | public String ajaxTestGrain(GateWayTestParam parameter) { |
| | | |
| | | //获取设备配置,只针对粮情设备进行执行 |
| | | |
| | |
| | | return "ERROR:为获取到系统中设备配置,取消执行"; |
| | | } |
| | | |
| | | Date dayTime = (Date) parameter.get("dayTime"); |
| | | Date dayTime = (Date) parameter.getDayTime(); |
| | | if (null == dayTime) dayTime = new Date(); |
| | | |
| | | Date start = DateUtil.getCurZero(dayTime); |