| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.Supervision; |
| | | import com.moral.api.mapper.SupervisionMapper; |
| | | import com.moral.api.service.MonitorPointService; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.api.service.SupervisionService; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private OrganizationService organizationService; |
| | | |
| | | @Autowired |
| | | private MonitorPointService monitorPointService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | int size = Integer.parseInt(params.get("size").toString()); |
| | | Object start = params.get("start"); |
| | | Object end = params.get("end"); |
| | | |
| | | |
| | | QueryWrapper<Supervision> supervisionQueryWrapper = new QueryWrapper<>(); |
| | | supervisionQueryWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | if (params.get("organizationId") != null) { |
| | | Integer orgId = Integer.parseInt(params.get("organizationId").toString()); |
| | | |
| | | //获取组织下所有子组织 |
| | | List<Organization> organizations = organizationService.getChildrenOrganizationsById(orgId); |
| | | List<Integer> orgIds = organizations.stream().map(Organization::getId).collect(Collectors.toList()); |
| | | orgIds.add(orgId); |
| | | QueryWrapper<MonitorPoint> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("city_code") |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .in("organization_id", orgIds); |
| | | |
| | | //根据组织id查询所有站点市级code |
| | | List<Object> cityCodes = monitorPointService.listObjs(queryWrapper); |
| | | |
| | | cityCodes = cityCodes.stream() |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | supervisionQueryWrapper.in("CONCAT(LEFT(city_code,4),'00')", cityCodes); |
| | | } else { |
| | | QueryWrapper<Supervision> supervisionQueryWrapper = new QueryWrapper<>(); |
| | | supervisionQueryWrapper.eq("is_delete", Constants.NOT_DELETE).in("organization_id", orgIds); |
| | | //如果指定了地区,就获取该组织及其子组织下该地区的。否则获取该组织及其子组织下所有的 |
| | | if (params.get("cityCode") != null) { |
| | | String cityCode = params.get("cityCode").toString(); |
| | | //如果是市级,就查询该市下所有县市区的,否则只查询该县市区的 |
| | | if (cityCode.endsWith("00")) { |
| | |
| | | supervisionQueryWrapper.eq("city_code", cityCode); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (start != null) { |
| | | supervisionQueryWrapper.ge("time", start); |