| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.config.Interceptor.UserHelper; |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.MonitorPointMapper; |
| | | import com.moral.api.mapper.OrganizationMapper; |
| | | import com.moral.api.pojo.vo.user.QxUser; |
| | | import com.moral.api.pojo.vo.device.DeviceVO; |
| | | import com.moral.api.pojo.vo.monitorPoint.MonitorPointVos; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.MonitorPointService; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.TokenUtils; |
| | | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Autowired |
| | | OrganizationMapper organizationMapper; |
| | | |
| | | @Autowired |
| | | MonitorPointMapper monitorPointMapper; |
| | | |
| | | |
| | | @Autowired |
| | | DeviceMapper deviceMapper; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | return rsList; |
| | | } |
| | | |
| | | /** |
| | | * 查询组织信息 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Organization> queryDevices() { |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | | Integer organizationId = (Integer) orgInfo.get("id"); |
| | | LambdaQueryWrapper<Organization> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Organization::getId,Organization::getAddress,Organization::getAreaName,Organization::getName); |
| | | wrapper.eq(Organization::getIsDelete,Constants.NOT_DELETE); |
| | | wrapper.orderByDesc(Organization::getCreateTime); |
| | | List<Organization> organizations; |
| | | if (organizationId==24){ |
| | | wrapper.eq(Organization::getParentId,organizationId); |
| | | organizations = organizationMapper.selectList(wrapper); |
| | | }else { |
| | | wrapper.eq(Organization::getId,organizationId); |
| | | organizations = organizationMapper.selectList(wrapper); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(organizations)){ |
| | | organizations.forEach(it ->{ |
| | | //查询站点 |
| | | // QueryWrapper<MonitorPoint> queryMonitorPointsWrapper = new QueryWrapper<>(); |
| | | // queryMonitorPointsWrapper.eq("organization_id", it.getId()); |
| | | // queryMonitorPointsWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | // List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(queryMonitorPointsWrapper); |
| | | List<MonitorPointVos> monitorPoints = monitorPointMapper.getMonitorPoint(it.getId()); |
| | | //查询站点对应的设备 |
| | | for (MonitorPointVos monitorPoint : monitorPoints) { |
| | | // List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPoint.getId()); |
| | | List<DeviceVO> listVo = deviceMapper.getListVo(monitorPoint.getId()); |
| | | monitorPoint.setMonitorPoint(listVo); |
| | | } |
| | | it.setMonitorPoint(monitorPoints); |
| | | } ); |
| | | } |
| | | return organizations; |
| | | } |
| | | } |