| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.entity.SpecialDeviceHistory; |
| | | import com.moral.api.entity.TbDaily; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.DailyMapper; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.mapper.SpecialDeviceMapper; |
| | | import com.moral.api.mapper.SysDictTypeMapper; |
| | | import com.moral.api.pojo.bo.ExcelBO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserListDTO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultCountDTO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; |
| | | import com.moral.api.pojo.enums.SysDictTypeEnum; |
| | | import com.moral.api.pojo.vo.excel.DailyVo; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.api.service.SpecialDeviceHistoryService; |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.SysDictTypeService; |
| | | import com.moral.constant.Constants; |
| | | |
| | | import com.moral.util.AmendUtils; |
| | |
| | | private HistorySecondCruiserMapper HistorySecondCruiserMapper; |
| | | |
| | | @Autowired |
| | | private SysDictTypeService sysDictTypeService; |
| | | |
| | | @Autowired |
| | | private SpecialDeviceHistoryService specialDeviceHistoryService; |
| | | |
| | | @Autowired |
| | |
| | | //获取当前用户信息 |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | | Integer userId = (Integer) userInfo.get("userId"); |
| | | List<Integer> integerList = new ArrayList<>(); |
| | | SysDictData listSys = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER_RANGE.getValue(),userId.toString()); |
| | | if(listSys.getDataValue().contains(",")){ |
| | | List<Integer> resultStr = Arrays.asList(listSys.getDataValue().split(",")).stream().map(Integer::parseInt).collect(Collectors.toList()); |
| | | integerList.addAll(resultStr); |
| | | }else { |
| | | Integer dataValue = Objects.nonNull(listSys.getDataValue())?Integer.parseInt(listSys.getDataValue()):0; |
| | | integerList.add(dataValue); |
| | | } |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | //获取所有子组织 |
| | | List<Organization> organizations = organizationService.getChildrenOrganizationsById(orgId); |
| | | List<Integer> orgIds = organizations.stream().map(Organization::getId).collect(Collectors.toList()); |
| | | orgIds.add(orgId); |
| | | integerList.addAll(orgIds); |
| | | QueryWrapper<SpecialDeviceHistory> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("mac", "name") |
| | | queryWrapper.select("DISTINCT mac, name").lambda(); |
| | | |
| | | //.eq("special_type", Constants.SPECIAL_DEVICE_CRUISER) |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .in("organization_id", orgIds); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE) |
| | | .in("organization_id", integerList); |
| | | return specialDeviceHistoryService.listMaps(queryWrapper); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<HistorySecondCruiserResultDTO> carTrajectoryNewAvg(Map<String, Object> params) { |
| | | double range = Double.valueOf(params.get("range").toString()); |
| | | String type = params.get("type").toString(); |
| | | params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Integer userId = (Integer) userInfo.get("userId"); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | params.put("orgId", orgId); |
| | | params.put("type","$."+params.get("type")); |
| | | List<Integer> integerList = new ArrayList<>(); |
| | | SysDictData listSys = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER_RANGE.getValue(),userId.toString()); |
| | | if(listSys.getDataValue().contains(",")){ |
| | | List<Integer> resultStr = Arrays.asList(listSys.getDataValue().split(",")).stream().map(Integer::parseInt).collect(Collectors.toList()); |
| | | integerList.addAll(resultStr); |
| | | }else { |
| | | Integer dataValue = Objects.nonNull(listSys.getDataValue())?Integer.parseInt(listSys.getDataValue()):0; |
| | | integerList.add(dataValue); |
| | | } |
| | | integerList.add(orgId); |
| | | params.put("orgIds", integerList); |
| | | params.put("type","$."+type); |
| | | //从秒数据表获取走航车数据 |
| | | List<HistorySecondCruiserListDTO> data = HistorySecondCruiserMapper.getCruiserDataNewAvg(params); |
| | | data.removeIf(o->{ |
| | |
| | | if(CollectionUtils.isEmpty(data)){ |
| | | return null; |
| | | } |
| | | return filterDataNew(data,range); |
| | | List<HistorySecondCruiserResultDTO> result = filterDataNew(data,range); |
| | | if(CollectionUtils.isNotEmpty(result)){ |
| | | SysDictData list = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER.getValue(),type); |
| | | if(list.getDataValue().contains(",")){ |
| | | List<String> resultStr = Arrays.asList(list.getDataValue().split(",")); |
| | | if(resultStr.size() % 2 ==0){ |
| | | result.forEach(it->{ |
| | | it.setAvgNum(numAvg(resultStr,it.getAvgNum())); |
| | | }); |
| | | } |
| | | }else { |
| | | BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Integer.parseInt(list.getDataValue())):BigDecimal.ZERO; |
| | | result.forEach(it->{ |
| | | it.setAvgNum(it.getAvgNum().add(dataValue)); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private BigDecimal numAvg(List<String> list , BigDecimal num){ |
| | | int nums = 1; |
| | | for (int i=0;i<list.size();i=i+2){ |
| | | if(num.compareTo(BigDecimal.valueOf(Integer.parseInt(list.get(i))))>= 0 ){ |
| | | return num.add(BigDecimal.valueOf(Integer.parseInt(list.get(nums)))); |
| | | } |
| | | nums+=2; |
| | | } |
| | | return num; |
| | | } |
| | | |
| | | @Override |
| | | public SpecialDevice getSpecialDeviceMapByMac(String mac) { |
| | | QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper(); |
| | |
| | | String time2 = params.get("time2").toString(); |
| | | String rsTime = getTime(time1, time2); |
| | | list.add(rsTime); |
| | | List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false); |
| | | // List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false); |
| | | // List<Map<String, Object>> maps = HistorySecondCruiserMapper.getCruiserData(params); |
| | | List<Map<String, Object>> maps = HistorySecondCruiserMapper.getAllCruiserData(params); |
| | | |
| | | if (ObjectUtils.isEmpty(maps)){ |
| | | return null; |
| | | } |
| | |
| | | map.put("time1",time3); |
| | | map.put("time2",time4); |
| | | map.put("mac",mac); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | // List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | List<Map<String, Object>> maps1 = HistorySecondCruiserMapper.getAllCruiserData(params); |
| | | if (ObjectUtils.isEmpty(maps1)){ |
| | | return null; |
| | | } |
| | |
| | | map.put("time1",time5); |
| | | map.put("time2",time6); |
| | | map.put("mac",mac); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | // List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | List<Map<String, Object>> maps1 = HistorySecondCruiserMapper.getAllCruiserData(params); |
| | | if (ObjectUtils.isEmpty(maps1)){ |
| | | return null; |
| | | } |
| | |
| | | |
| | | |
| | | for (Map<String, Object> map : maps) { |
| | | // String flylon = map.get("flylon").toString(); |
| | | // String flylat = map.get("flylat").toString(); |
| | | // String s = flylon + "-" + flylat; |
| | | // if (Double.parseDouble(map.get("a34004").toString())>200){ |
| | | // |
| | | // } |
| | | pm25List.add(Double.parseDouble(map.get("a34004").toString())); |
| | | pm10List.add(Double.parseDouble(map.get("a34002").toString())); |
| | | COList.add(Double.parseDouble(map.get("a21005").toString())); |
| | | SO2List.add(Double.parseDouble(map.get("a21026").toString())); |
| | | NO2List.add(Double.parseDouble(map.get("a21004").toString())); |
| | | O3List.add(Double.parseDouble(map.get("a05024").toString())); |
| | | VOCList.add(Double.parseDouble(map.get("a99054").toString())); |
| | | |
| | | Map value = JSON.parseObject(map.get("value").toString(), Map.class); |
| | | if (!ObjectUtils.isEmpty(value.get("a34004"))){ |
| | | pm25List.add(Double.parseDouble(value.get("a34004").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a34002"))){ |
| | | pm10List.add(Double.parseDouble(value.get("a34002").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a21005"))){ |
| | | COList.add(Double.parseDouble(value.get("a21005").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a21026"))){ |
| | | SO2List.add(Double.parseDouble(value.get("a21026").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a21004"))){ |
| | | NO2List.add(Double.parseDouble(value.get("a21004").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a05024"))){ |
| | | O3List.add(Double.parseDouble(value.get("a05024").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a99054"))){ |
| | | VOCList.add(Double.parseDouble(value.get("a99054").toString())); |
| | | } |
| | | } |
| | | |
| | | //获取平均值 |