| | |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiCommonDevice; |
| | | import com.fzzy.api.data.DepotType; |
| | | import com.fzzy.api.data.GatewayDeviceType; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.gateway.GatewayUtils; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | |
| | | |
| | | List<GatewayDevice> result = new ArrayList<>(); |
| | | |
| | | GatewayDevice cacheDevice; |
| | | ApiCommonDevice commonDevice; |
| | | for (GatewayDevice device : list) { |
| | | 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()); |
| | | commonDevice = Constant.getCommonDeviceCache(device.getDeviceSn()); |
| | | if (null != commonDevice) { |
| | | device.setIp(commonDevice.getIp()); |
| | | device.setPort(commonDevice.getPort()); |
| | | device.setStatus(commonDevice.getStatus()); |
| | | device.setOnlineTime(commonDevice.getOnlineTime()); |
| | | } |
| | | result.add(device); |
| | | } |
| | |
| | | GatewayDevice data2 = new GatewayDevice(); |
| | | BeanUtils.copyProperties(data, data2); |
| | | |
| | | |
| | | if (null == data2.getStatus()) { |
| | | data.setStatus(Constant.YN_Y); |
| | | |
| | | if (GatewayDeviceType.TYPE_07.equals(data2.getType())) { |
| | | data.setStatus(Constant.YN_N); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (null == data2.getDeviceSn()) { |
| | | if (null != data2.getIp()) { |
| | | data.setDeviceSn(data2.getIp()); |
| | | } else { |
| | | data.setDeviceSn(data2.getDeviceId()); |
| | | } |
| | | } |
| | | |
| | | if (null == data2.getDepotType()) { |
| | | data2.setDepotType(DepotType.TYPE_01.getCode()); |
| | | } |
| | | |
| | | if (null == data2.getId()) { |
| | |
| | | } |
| | | flushCache(); |
| | | } |
| | | |
| | | public void updateData(GatewayDevice device) { |
| | | device.setStatus(Constant.YN_Y); |
| | | |
| | | gatewayDeviceRep.save(device); |
| | | |
| | | flushCacheOne(device); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * gatewayDeviceService#delData |
| | |
| | | for (GatewayDevice device : list) { |
| | | GatewayUtils.add2Cache(device); |
| | | } |
| | | } |
| | | |
| | | private void flushCacheOne(GatewayDevice device) { |
| | | GatewayUtils.add2Cache(device); |
| | | } |
| | | |
| | | |
| | |
| | | for (GatewayDevice device : list) { |
| | | device.setIp(commonDevice.getIp()); |
| | | device.setPort(commonDevice.getPort()); |
| | | //device.setOnlineTime(new Date()); |
| | | device.setStatus(Constant.YN_N); |
| | | |
| | | GatewayUtils.add2Cache(device); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |