| | |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.RegionCodeUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | |
| | | DeviceService deviceService; |
| | | |
| | | @Override |
| | | public List<MonitorPoint> query(MonitorPointQueryForm form) { |
| | | public List<MonitorPoint> queryByOrgIdAndRegionCode(MonitorPointQueryForm form) { |
| | | //取参 |
| | | Integer organizationId = form.getOrganizationId(); |
| | | Integer regionCode = form.getRegionCode(); |
| | | String region = RegionCodeUtils.regionCodeConvertToName(regionCode); |
| | | String region = null; |
| | | if (regionCode != null) { |
| | | region = RegionCodeUtils.regionCodeConvertToName(regionCode); |
| | | } |
| | | |
| | | //查询子组织 |
| | | List<Organization> childrenOrganization = organizationService.getChildrenOrganizationsById(organizationId); |
| | | List<Integer> organizationIds = new ArrayList<>(); |
| | |
| | | organizationIds.add(organizationId); |
| | | //查询站点 |
| | | QueryWrapper<MonitorPoint> queryMonitorPointsWrapper = new QueryWrapper<>(); |
| | | queryMonitorPointsWrapper.eq(region,regionCode); |
| | | queryMonitorPointsWrapper.in("organization_id",organizationIds); |
| | | |
| | | //如果region不为空,就查询当前组织,所选城市下所有站点及设备信息 |
| | | //如果region为空,则查询当前组织下所有的站点和设备 |
| | | if (region != null){ |
| | | queryMonitorPointsWrapper.eq(region, regionCode); |
| | | } |
| | | queryMonitorPointsWrapper.in("organization_id", organizationIds); |
| | | queryMonitorPointsWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(queryMonitorPointsWrapper); |
| | | //查询站点对应的设备 |
| | |
| | | } |
| | | return monitorPoints; |
| | | } |
| | | |
| | | @Override |
| | | public List<MonitorPoint> queryAllMonitorPoints(Integer organizationId) { |
| | | //查询子组织 |
| | | List<Organization> childrenOrganization = organizationService.getChildrenOrganizationsById(organizationId); |
| | | List<Integer> organizationIds = new ArrayList<>(); |
| | | for (Organization organization : childrenOrganization) { |
| | | organizationIds.add(organization.getId()); |
| | | } |
| | | organizationIds.add(organizationId); |
| | | //查询站点 |
| | | QueryWrapper<MonitorPoint> queryMonitorPointsWrapper = new QueryWrapper<>(); |
| | | queryMonitorPointsWrapper.select("id","name"); |
| | | queryMonitorPointsWrapper.in("organization_id",organizationIds); |
| | | queryMonitorPointsWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(queryMonitorPointsWrapper); |
| | | return monitorPoints; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |