| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.moral.api.config.Interceptor.UserHelper; |
| | | import com.moral.api.dto.MonitoringStationDTO; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | |
| | | import com.moral.api.mapper.MonitorPointMapper; |
| | | import com.moral.api.mapper.SensorMapper; |
| | | import com.moral.api.pojo.form.device.MonitorPointQueryForm; |
| | | import com.moral.api.pojo.vo.user.QxUser; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.HistoryDailyService; |
| | | import com.moral.api.service.HistoryHourlyService; |
| | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import springfox.documentation.schema.Entry; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | return resultList; |
| | | } |
| | | |
| | | /** |
| | | * 根据用户查询站点 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MonitorPoint> getOrganizations() { |
| | | QueryWrapper<MonitorPoint> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("id","name"); |
| | | QxUser user = UserHelper.getCurrentUser(); |
| | | Integer organizationId = user.getOrganizationId(); |
| | | List<Integer> monitorPointiIds = monitorPointMapper.getMonitorPointiId(organizationId); |
| | | if (organizationId!=24){ |
| | | wrapper.in("id",monitorPointiIds); |
| | | } |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(wrapper); |
| | | for (int i = 0; i < monitorPoints.size(); i++) { |
| | | List<Device> organizationDevice = deviceService.getOrganizationDevice(monitorPoints.get(i).getId()); |
| | | if (ObjectUtils.isEmpty(organizationDevice)){ |
| | | monitorPoints.remove(i); |
| | | i--; |
| | | } |
| | | } |
| | | return monitorPoints; |
| | | } |
| | | |
| | | |
| | | private List<MonitoringStationDTO> resultList(List<HistoryDaily> historyDailyByMacAndTimeSlot){ |
| | | List<MonitoringStationDTO> list = new ArrayList<>(); |
| | | if(CollectionUtils.isEmpty(historyDailyByMacAndTimeSlot)){ |
| | | return list; |
| | | } |
| | | //海城分组均值 海州 p5dnd7a0000001 -响堂 p5dnd7a0000002 -兴海 p5dnd7a0000003 |
| | | List<String> hzRoad = Arrays.asList("p5dnd7a0245491","p5dnd7a0392159","p5dnd7a0243605","p5dnd7a0392176"); |
| | | List<String> xtRoad = Arrays.asList("p5dnd7a0243603","p5dnd7a0391986","p5dnd7a0392003","p5dnd7a0392144","p5dnd7a0392167","p5dnd7a0391990"); |
| | | List<String> xhRoad = Arrays.asList("p5dnd7a0392158","p5dnd7a0392173","p5dnd7a0391975","p5dnd7a0392153","p5dnd7a0391961","p5dnd7a0243608","p5dnd7a0243618"); |
| | | List<HistoryDaily> hcHz= new ArrayList<>(); |
| | | List<HistoryDaily> xtHz= new ArrayList<>(); |
| | | List<HistoryDaily> xhHz= new ArrayList<>(); |
| | | for(HistoryDaily h : historyDailyByMacAndTimeSlot) { |
| | | HistoryDaily historyDaily = new HistoryDaily(); |
| | | historyDaily.setTime( h.getTime()); |
| | | historyDaily.setValue(h.getValue()); |
| | | if(hzRoad.contains(h.getMac())){ |
| | | historyDaily.setMac("p5dnd7a0000001"); |
| | | hcHz.add(historyDaily); |
| | | }else if(xtRoad.contains(h.getMac())){ |
| | | historyDaily.setMac("p5dnd7a0000002"); |
| | | xtHz.add(historyDaily); |
| | | }else if(xhRoad.contains(h.getMac())){ |
| | | historyDaily.setMac("p5dnd7a0000003"); |
| | | xhHz.add(historyDaily); |
| | | } |
| | | } |
| | | if(CollectionUtils.isNotEmpty(hcHz)){ |
| | | historyDailyByMacAndTimeSlot.addAll(hcHz); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(xtHz)){ |
| | | historyDailyByMacAndTimeSlot.addAll(xtHz); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(xhHz)){ |
| | | historyDailyByMacAndTimeSlot.addAll(xhHz); |
| | | } |
| | | Map<String,Map<String,ArrayList<Double>>> resultMap = new HashMap<>(); |
| | | for(HistoryDaily h : historyDailyByMacAndTimeSlot) { |
| | |
| | | wrapper.eq(Device::getIsDelete,0); |
| | | Map<String,String> deviceMap = new HashMap<>(); |
| | | wrapper.list().forEach(it->deviceMap.put(it.getMac(),it.getName())); |
| | | |
| | | deviceMap.put("p5dnd7a0000001","海州街道均值"); |
| | | deviceMap.put("p5dnd7a0000002","响堂街道均值"); |
| | | deviceMap.put("p5dnd7a0000003","兴海街道均值"); |
| | | for (MonitoringStationDTO m :compositeListResult ){ |
| | | MonitoringStationDTO monit = new MonitoringStationDTO(); |
| | | String mac = m.getMac(); |