jiazx0107@163.com
2023-11-08 768308ab47041062d9e97745099784acf297286b
src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java
@@ -16,7 +16,6 @@
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;
@@ -62,28 +61,27 @@
    /**
     * 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();
    }
@@ -105,10 +103,6 @@
    }
    /**
     * gatewayDeviceService#flushCache
     */
    @Expose
    public void flushCache() {
        List<GatewayDevice> list = listAll();
        if (null == list || list.isEmpty()) return;
@@ -119,6 +113,9 @@
    /**
     * gatewayDeviceService#ajaxTestWeight
     * 地磅推送测试