| | |
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.ExampleUtil;
|
| | | import com.moral.common.util.RedisUtils;
|
| | | import com.moral.entity.DeviceVersion;
|
| | | import com.moral.mapper.DeviceVersionMapper;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import org.apache.commons.collections.MapUtils;
|
| | |
| | | private Class ENTITY_CLASS = Device.class;
|
| | | @Resource
|
| | | OrganizationMapper orgMapper;
|
| | | @Resource
|
| | | DeviceVersionMapper deviceVersionMapper;
|
| | | @Resource
|
| | | RedisUtils redisUtils;
|
| | | @Override
|
| | |
| | | simpleDevice.setMac(device.getMac()); // mac
|
| | | simpleDevice.setMonitorPointId(device.getMonitorPointId());// 监控地id
|
| | | simpleDevice.setOrganizationIds(device.getOrganizationIds());// 组织数组
|
| | | simpleDevice.setDeviceVersion(device.getDeviceVersion());
|
| | | redisUtils.set(key,simpleDevice);
|
| | | }
|
| | | private Device getDeviceFromRedis(String mac) {
|
| | |
| | | */
|
| | | private void refreshDeviceInRedis(String mac){
|
| | | if(!StringUtils.isBlank(mac)){
|
| | | Device devQuery = new Device();
|
| | | devQuery.setMac(mac);
|
| | | Device device = deviceMapper.selectOne(devQuery);
|
| | | if(device.getMonitorPointId()!=null){
|
| | | List<Integer> orgIds = monitorPointMapper.selectOrganizationIds(device.getMonitorPointId());
|
| | | device.setOrganizationIds(orgIds);
|
| | | }
|
| | | String key = "device_"+mac;
|
| | | redisUtils.set(key,device);
|
| | | Device device = deviceMapper.selectWithOrgIdsByMac(mac);
|
| | | setDeviceToRedis(mac,device);
|
| | | }else
|
| | | {
|
| | | log.warn("param mac is null in method [refreshDeviceInRedis]");
|