| | |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.gateway.hx2023.ScConstant; |
| | | import com.fzzy.gateway.hx2023.data.*; |
| | | 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; |
| | | 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#updateSave |
| | | * |
| | | * @param entity |
| | | * @param data |
| | | */ |
| | | @DataResolver |
| | | public void updateSave(GatewayDevice entity) { |
| | | GatewayDevice data = new GatewayDevice(); |
| | | BeanUtils.copyProperties(entity, data); |
| | | |
| | | if (null == data.getId()) { |
| | | data.setId(ContextUtil.getUUID()); |
| | | } |
| | | |
| | | |
| | | if (null == data.getDeviceSn()) { |
| | | if (null != entity.getIp()) { |
| | | data.setDeviceSn(entity.getIp()); |
| | | public void updateSave(GatewayDevice data) { |
| | | GatewayDevice data2 = new GatewayDevice(); |
| | | BeanUtils.copyProperties(data, data2); |
| | | |
| | | if (null == data2.getDeviceSn()) { |
| | | if (null != data2.getIp()) { |
| | | data.setDeviceSn(data2.getIp()); |
| | | } else { |
| | | data.setDeviceSn(data.getDeviceId()); |
| | | data.setDeviceSn(data2.getDeviceId()); |
| | | } |
| | | } |
| | | |
| | | gatewayDeviceRep.save(data); |
| | | |
| | | if (null == data2.getId()) { |
| | | data2.setId(ContextUtil.getUUID()); |
| | | gatewayDeviceRep.save(data2); |
| | | }else{ |
| | | gatewayDeviceRep.save(data2); |
| | | } |
| | | flushCache(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * gatewayDeviceService#flushCache |
| | | */ |
| | | @Expose |
| | | public void flushCache() { |
| | | List<GatewayDevice> list = listAll(); |
| | | if (null == list || list.isEmpty()) return; |
| | |
| | | GatewayUtils.add2Cache(device); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String ajaxTestWeight(GateWayTestParam parameter) { |
| | | double weigh = (double) parameter.getWeight(); |
| | | //double weigh = Double.parseDouble("3500.0"); |
| | | public String ajaxTestWeight() { |
| | | //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.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()); |