| | |
| | | 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]");
|
| | |
| | | @Override
|
| | | public PageBean queryByPageBean(PageBean pageBean) {
|
| | | Example example = ExampleUtil.generateExample(ENTITY_CLASS,pageBean);
|
| | | addDeletesToExample(example);
|
| | | // addDeletesToExample(example);
|
| | | if(pageBean.getPageSize()>0){
|
| | | PageHelper.startPage(pageBean.getPageIndex(),pageBean.getPageSize());
|
| | | }
|
| | | List<Device> organizationList = deviceMapper.selectWithRelationData(example);
|
| | | return new PageBean(organizationList);
|
| | | List<Device> deviceList = deviceMapper.selectWithRelationData(example);
|
| | | return new PageBean(deviceList);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | return deviceMapper.getDevicesByProfession(parameters);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Device> getDevicesByOrganizationId(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("organizationId"), "param.is.null");
|
| | | return deviceMapper.getDevicesByOrganizationId(parameters);
|
| | | }
|
| | |
|
| | | }
|