|  |  |  | 
|---|
|  |  |  | return this.monitorPointMapper.selectByPrimaryKey(mpointId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Description: 如果站点中没有设备则不会返回站点 | 
|---|
|  |  |  | * @Param: [parameters] | 
|---|
|  |  |  | * @return: java.util.List<com.moral.entity.MonitorPoint> | 
|---|
|  |  |  | * @Author: 下雨听风 | 
|---|
|  |  |  | * @Date: 2020/12/2 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<MonitorPoint> getMonitorPointsAndDevicesByRegion(Map<String, Object> parameters) { | 
|---|
|  |  |  | //校验参数 | 
|---|
|  |  |  | 
|---|
|  |  |  | return monitorPoints; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Description: 如果站点中没有设备也会返回站点 | 
|---|
|  |  |  | * @Param: [parameters] | 
|---|
|  |  |  | * @return: java.util.List<com.moral.entity.MonitorPoint> | 
|---|
|  |  |  | * @Author: 下雨听风 | 
|---|
|  |  |  | * @Date: 2020/12/2 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<MonitorPoint> getMonitorPointsByRegionAndOrgId(Map<String, Object> parameters) { | 
|---|
|  |  |  | public List<MonitorPoint> getMonitorPointsAndDevicesByRegionNew(Map<String, Object> parameters) { | 
|---|
|  |  |  | //校验参数 | 
|---|
|  |  |  | Object organizationId = parameters.remove("organizationId"); | 
|---|
|  |  |  | //判断参数是否为null,如果为null则抛出自定义异常,msgKey为异常信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | criteria.andEqualTo(parameters.get("regionType") + "Code", parameters.remove("regionCode")); | 
|---|
|  |  |  | List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询所有设备信息 | 
|---|
|  |  |  | Example deviceExample = new Example(Device.class); | 
|---|
|  |  |  | Criteria deviceCriteria = deviceExample.createCriteria(); | 
|---|
|  |  |  | deviceCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE); | 
|---|
|  |  |  | List<Device> devicesInfo = deviceMapper.selectByExample(deviceExample); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取所有站点信息 | 
|---|
|  |  |  | Example monitorExample = new Example(MonitorPoint.class); | 
|---|
|  |  |  | Criteria monitorCriteria = monitorExample.createCriteria(); | 
|---|
|  |  |  | monitorCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE); | 
|---|
|  |  |  | List<MonitorPoint> monitorPointInfo = monitorPointMapper.selectByExample(monitorExample); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取所有设备附加属性 | 
|---|
|  |  |  | List<DeviceProperty> devicePropertyList = devicePropertyMapper.selectAll(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //附加属性全部添加到设备实体中 | 
|---|
|  |  |  | for (Device d : devicesInfo) { | 
|---|
|  |  |  | for (DeviceProperty dp : devicePropertyList) { | 
|---|
|  |  |  | if (dp.getId().equals(d.getId())) { | 
|---|
|  |  |  | d.setDeviceProperty(dp); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //把对应的设备信息添加到站点中 | 
|---|
|  |  |  | Map<Integer, List<Device>> monitorDeviceMap = new HashMap(); | 
|---|
|  |  |  | for (MonitorPoint m : monitorPointInfo) { | 
|---|
|  |  |  | List<Device> monitorDevices = new ArrayList<>(); | 
|---|
|  |  |  | for (Device d : devicesInfo) { | 
|---|
|  |  |  | if (m.getId().equals(d.getMonitorPointId())) { | 
|---|
|  |  |  | monitorDevices.add(d); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | monitorDeviceMap.put(m.getId(), monitorDevices); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //对应地区Code的迭代器,向站点中添加设备信息 | 
|---|
|  |  |  | Iterator<MonitorPoint> iterator = monitorPoints.iterator(); | 
|---|
|  |  |  | while (iterator.hasNext()) { | 
|---|
|  |  |  | MonitorPoint monitorPoint = iterator.next(); | 
|---|
|  |  |  | for (Map.Entry<Integer, List<Device>> entry : monitorDeviceMap.entrySet()) { | 
|---|
|  |  |  | if (monitorPoint.getId().equals(entry.getKey())) { | 
|---|
|  |  |  | if (!CollectionUtils.isEmpty(entry.getValue())) { | 
|---|
|  |  |  | monitorPoint.setDevices(entry.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return monitorPoints; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|