| | |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiCommonDevice; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.async.fzzy40.Fzzy40CommonService; |
| | | import com.fzzy.gateway.GatewayUtils; |
| | | import com.fzzy.gateway.api.GatewayRemoteManager; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.gateway.service.repository.GatewayDeviceRep; |
| | | import com.fzzy.mqtt.MqttProviderConfig; |
| | | import com.fzzy.mqtt.MqttPublishService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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; |
| | | |
| | | @Slf4j |
| | |
| | | |
| | | List<GatewayDevice> result = new ArrayList<>(); |
| | | |
| | | ApiCommonDevice apiCommonDevice; |
| | | GatewayDevice cacheDevice; |
| | | for (GatewayDevice device : list) { |
| | | |
| | | apiCommonDevice = Constant.getCommonDeviceCache(device.getDeviceSn()); |
| | | if (null != apiCommonDevice) { |
| | | device.setIp(apiCommonDevice.getIp()); |
| | | device.setPort(apiCommonDevice.getPort()); |
| | | device.setStatus(apiCommonDevice.getStatus()); |
| | | device.setOnlineTime(apiCommonDevice.getOnlineTime()); |
| | | device.setStatus(Constant.YN_Y); |
| | | cacheDevice = GatewayUtils.getCacheByDeviceId(device.getDeviceId()); |
| | | if (null != cacheDevice) { |
| | | device.setIp(cacheDevice.getIp()); |
| | | device.setPort(cacheDevice.getPort()); |
| | | device.setStatus(cacheDevice.getStatus()); |
| | | device.setOnlineTime(cacheDevice.getOnlineTime()); |
| | | } |
| | | result.add(device); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // /** |
| | | // * gatewayDeviceService#getQuery |
| | | // * |
| | | // * @return |
| | | // */ |
| | | // @DataProvider |
| | | // public GateWayTestParam getQuery() { |
| | | // GateWayTestParam param = new GateWayTestParam(); |
| | | // param.setDayTime(new Date()); |
| | | // param.setCarNumber("川A12345"); |
| | | // param.setEnd(new Date()); |
| | | // param.setStart(new Date()); |
| | | // param.setWeight(25000.00); |
| | | // return param; |
| | | // } |
| | | |
| | | /** |
| | | * gatewayDeviceService#updateSave |
| | |
| | | log.info("-----------test-------------------"); |
| | | return "SUCCESS"; |
| | | } |
| | | |
| | | /** |
| | | * 根据实际通讯分机设置,当前分机在线 |
| | | * |
| | | * @param commonDevice 实际通讯设备 |
| | | */ |
| | | public void onlineByCommonDevice(ApiCommonDevice commonDevice) { |
| | | List<GatewayDevice> list = GatewayUtils.getCacheByDeviceSn2(commonDevice.getSn()); |
| | | if (null == list || list.isEmpty()) return; |
| | | |
| | | for (GatewayDevice device : list) { |
| | | device.setIp(commonDevice.getIp()); |
| | | device.setPort(commonDevice.getPort()); |
| | | device.setOnlineTime(new Date()); |
| | | device.setStatus(Constant.YN_Y); |
| | | |
| | | GatewayUtils.add2Cache(device); |
| | | } |
| | | } |
| | | |
| | | public void OfflineByCommonDevice(ApiCommonDevice commonDevice) { |
| | | List<GatewayDevice> list = GatewayUtils.getCacheByDeviceSn2(commonDevice.getSn()); |
| | | if (null == list || list.isEmpty()) return; |
| | | |
| | | for (GatewayDevice device : list) { |
| | | device.setIp(commonDevice.getIp()); |
| | | device.setPort(commonDevice.getPort()); |
| | | //device.setOnlineTime(new Date()); |
| | | device.setStatus(Constant.YN_N); |
| | | |
| | | GatewayUtils.add2Cache(device); |
| | | } |
| | | } |
| | | } |