From 5ef407e617576a83c9b8c25ce510f263ed031d03 Mon Sep 17 00:00:00 2001 From: swb <jpy123456> Date: Wed, 03 Jul 2024 15:02:17 +0800 Subject: [PATCH] fix:走航车排名接口提交 --- screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java | 81 ++++++---------------------------------- 1 files changed, 13 insertions(+), 68 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java index 0d5d1c2..ad3020c 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java @@ -1,7 +1,9 @@ package com.moral.api.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.moral.api.config.Interceptor.UserHelper; +import com.moral.api.entity.SecondCruiserSort; import com.moral.api.entity.SysDictData; import com.moral.api.exception.BusinessException; import com.moral.api.mapper.*; @@ -51,6 +53,9 @@ @Autowired private DustldMapper dustldMapper; + + @Autowired + private SecondCruiserSortMapper secondCruiserSortMapper; /** * ������������������ @@ -467,74 +472,14 @@ * @return */ @Override - public List<DustForm> sort(String mac, String startTime, String endTime) { - SysDictData list = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER.getValue(),"dustld"); - Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); - Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); - Integer orgId = (Integer) orgInfo.get("id"); - - List<Integer> orgList = organizationMapper.orgIdSpecialDevList(orgId,mac); - if(CollectionUtils.isEmpty(orgList)){ - throw new BusinessException("������������������������������������"); - } - - HashMap<String, Object> params = new HashMap<>(); - params.put("mac",mac); - params.put("startTime",startTime); - params.put("endTime",endTime); - List<Map<String, Object>> dusts = historySecondCruiserMapper.getDusts(params); - Map<String, List<DustldDTO>> collect = manageCoordinateMapper.CompareTo(orgList.get(0)).stream().collect(Collectors.groupingBy(o -> o.getName())); - if (ObjectUtils.isEmpty(dusts) || ObjectUtils.isEmpty(collect)){ - return null; - } - Set<String> strings = collect.keySet(); - ArrayList<DustForm> list1 = new ArrayList<>(); - for (String string : strings) { - DustForm dustForm = new DustForm(); - ArrayList<Double> doubleArrayList = new ArrayList<>(); - List<DustldDTO> dustldDTOS = collect.get(string); - for (DustldDTO dustldDTO : dustldDTOS) { - String flyLat = dustldDTO.getFlyLat(); - String flyLon = dustldDTO.getFlyLon(); - if (flyLon==null && flyLat==null){ - continue; - } - double latDouble1 = Double.parseDouble(flyLat); - double lonDouble1 = Double.parseDouble(flyLon); - for (Map<String, Object> dust : dusts) { - String flyLat1 = Objects.nonNull(dust.get("flyLat")) ? dust.get("flyLat").toString() :"0"; - String flyLon1 = Objects.nonNull(dust.get("flyLon")) ? dust.get("flyLon").toString() :"0"; - double latDouble = Double.parseDouble(flyLat1); - double lonDouble = Double.parseDouble(flyLon1); -// String flyLon1 = dust.get("flyLon").toString(); - if (latDouble1==latDouble && lonDouble1==lonDouble){ - Double dustld = Objects.nonNull(dust.get("dustld"))?Double.parseDouble(dust.get("dustld").toString()):0d; - if(list.getDataValue().contains(",")){ - List<String> resultStr = Arrays.asList(list.getDataValue().split(",")); - if(resultStr.size() % 2 ==0){ - dustld = numAvg(resultStr,BigDecimal.valueOf(dustld)).doubleValue(); - } - }else { - BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Double.parseDouble(list.getDataValue())):BigDecimal.ZERO; - dustld = BigDecimal.valueOf(dustld).add(dataValue).doubleValue(); - } - doubleArrayList.add(dustld); - break; - } - } - } - if (ObjectUtils.isEmpty(doubleArrayList)){ - continue; - } - Double ListAva = doubleArrayList.stream() .collect(Collectors.averagingDouble(Double::doubleValue)); - double rsAvg = new BigDecimal(ListAva/1000).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); - dustForm.setRoad(string); - dustForm.setValue(rsAvg); - list1.add(dustForm); - } - //������ - list1.sort(Comparator.comparing(DustForm::getValue).reversed()); - return list1; + public List<SecondCruiserSort> sort(String mac, String startTime, String endTime) { + String s = DateUtils.stringToDateString(startTime, "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd"); + LambdaQueryWrapper<SecondCruiserSort> wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SecondCruiserSort::getMac,mac); + wrapper.eq(SecondCruiserSort::getTime,s); + wrapper.orderByDesc(SecondCruiserSort::getValue); + List<SecondCruiserSort> secondCruiserSorts = secondCruiserSortMapper.selectList(wrapper); + return secondCruiserSorts; } -- Gitblit v1.8.0