From e3bac98f092a10c0e897143bece3abbcc59469f2 Mon Sep 17 00:00:00 2001 From: cjl <276999030@qq.com> Date: Fri, 27 Oct 2023 10:06:24 +0800 Subject: [PATCH] fix:小程序提交 --- screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java | 94 +++++++++++++++++++++------------------------- 1 files changed, 43 insertions(+), 51 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 85a16fa..aeefda9 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 @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.system.ApplicationHome; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import org.springframework.web.multipart.MultipartFile; @@ -89,29 +90,25 @@ for (TimeForm timeForm : tables) { String start = timeForm.getStart(); String end = timeForm.getEnd(); - List<Double> dust = historySecondCruiserMapper.getDust(start, end, mac); + List<String> dust = historySecondCruiserMapper.getDust(start, end, mac); ArrayList<Double> rsDouble = new ArrayList<>(); - for (Double aDouble : dust) { - double v =0.0; + for (String s : dust) { + double aDouble = Double.parseDouble(s); + if (aDouble>=0 && aDouble<40 ){ - v = aDouble + 170; + aDouble = aDouble + 170; + }else if (aDouble>=40 && aDouble<60){ + aDouble = aDouble + 130; + }else if (aDouble>=60 && aDouble<100 ){ + aDouble = aDouble + 110; + }else if (aDouble>=100 && aDouble<150){ + aDouble = aDouble + 70; + }else if (aDouble>=150 && aDouble<180){ + aDouble = aDouble + 30; + }else { + aDouble= aDouble+0; } - if (aDouble>=40 && aDouble<60 ){ - v = aDouble + 130; - } - if (aDouble>=60 && aDouble<100 ){ - v = aDouble + 110; - } - if (aDouble>=100 && aDouble<150 ){ - v = aDouble + 70; - } - if (aDouble>=150 && aDouble<180 ){ - v = aDouble + 30; - } - if (aDouble>=180){ - v= aDouble; - } - rsDouble.add(v); + rsDouble.add(aDouble); } list.addAll(rsDouble); } @@ -275,15 +272,16 @@ private MaxRoadMapper maxRoadMapper; @Override + @Transactional public Map<String, Object> dailyDustlds(List<MultipartFile> file,Map<String, Object> params) { 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"); - String time1 = params.get("time1").toString(); + String time1 = params.get("startTime").toString(); String dateString1 = DateUtils.stringToDateString(time1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN, DateUtils.yyyy_MM_dd_HH_mm_CN); String rsTime1 = dateString1.substring(5, 14); - String time2 = params.get("time2").toString(); + String time2 = params.get("endTime").toString(); String dateString2 = DateUtils.stringToDateString(time2, DateUtils.yyyy_MM_dd_HH_mm_ss_EN, DateUtils.yyyy_MM_dd_HH_mm_CN); String rsTime2 = dateString2.substring(5, 14); HashMap<String, Object> rsMap = new HashMap<>(); @@ -291,7 +289,7 @@ Map<String, List<DustldDTO>> collect = manageCoordinateMapper.CompareTo(orgId).stream().collect(Collectors.groupingBy(o -> o.getName())); Set<String> strings = collect.keySet(); ArrayList<DustForm> list1 = new ArrayList<>(); - ArrayList<DustForm> list2 = new ArrayList<>(); + //��������������������� StringBuilder builder = new StringBuilder(); int i = 1; @@ -303,29 +301,29 @@ for (DustldDTO dustldDTO : dustldDTOS) { String flyLat = dustldDTO.getFlyLat(); String flyLon = dustldDTO.getFlyLon(); -// if (flyLon==null && flyLat==null){ -// continue; -// } + 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 (flyLat1.equals(flyLat) && flyLon1.equals(flyLon)){ + if (latDouble1==latDouble && lonDouble1==lonDouble){ Double dustld = Objects.nonNull(dust.get("dustld"))?Double.parseDouble(dust.get("dustld").toString()):0d; if (dustld>=0 && dustld<40 ){ dustld = dustld + 170; - } - if (dustld>=40 && dustld<60 ){ + }else if (dustld>=40 && dustld<60){ dustld = dustld + 130; - } - if (dustld>=60 && dustld<100 ){ + }else if (dustld>=60 && dustld<100 ){ dustld = dustld + 110; - } - if (dustld>=100 && dustld<150 ){ + }else if (dustld>=100 && dustld<150){ dustld = dustld + 70; - } - if (dustld>=150 && dustld<180 ){ + }else if (dustld>=150 && dustld<180){ dustld = dustld + 30; } doubleArrayList.add(dustld); @@ -340,9 +338,10 @@ double rsAvg = new BigDecimal(ListAva/1000).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); dustForm.setRoad(string); dustForm.setValue(rsAvg); + list1.add(dustForm); if (rsAvg>=0.3){ builder.append("("+i+")"+string); - list1.add(dustForm); + i++; //������������������ QueryWrapper<MaxRoad> wrapper = new QueryWrapper<>(); wrapper.eq("name",string); @@ -355,18 +354,14 @@ maxRoad.setTime(DateUtils.getDate(time1,DateUtils.yyyy_MM_dd_EN)); maxRoadMapper.insert(maxRoad); } - - }else { - list2.add(dustForm); } } long timestamp2 = System.currentTimeMillis(); log.info(timestamp2-timestamp+""); //������ list1.sort(Comparator.comparing(DustForm::getValue).reversed()); - list2.sort(Comparator.comparing(DustForm::getValue).reversed()); rsMap.put("list1",list1); - rsMap.put("list2",list2); + //������������������������������ ArrayList<Map<String, Object>> list3 = new ArrayList<>(); @@ -374,18 +369,15 @@ wrapper.lt("time",DateUtils.getDate(time1,DateUtils.yyyy_MM_dd_EN)); wrapper.orderByDesc("time"); - MaxRoad maxRoad = maxRoadMapper.selectOne(wrapper); - String dateString3 = DateUtils.dateToDateString(maxRoad.getTime(), DateUtils.yyyy_MM_dd_CN); + List<MaxRoad> maxRoads = maxRoadMapper.selectList(wrapper); + String dateString3 = DateUtils.dateToDateString(maxRoads.get(0).getTime(), DateUtils.yyyy_MM_dd_CN); QueryWrapper<MaxRoad> wrapper2 = new QueryWrapper<>(); - wrapper2.eq("time",maxRoad.getTime()); - List<MaxRoad> maxRoads = maxRoadMapper.selectList(wrapper2); + wrapper2.eq("time",maxRoads.get(0).getTime()); + List<MaxRoad> maxRoads1 = maxRoadMapper.selectList(wrapper2); - //������������ - ArrayList<DustForm> dustForms = new ArrayList<>(); - dustForms.addAll(list1); - dustForms.addAll(list2); - for (MaxRoad road : maxRoads) { - for (DustForm dustForm : dustForms) { + //������������������������������ + for (MaxRoad road : maxRoads1) { + for (DustForm dustForm : list1) { if (road.getName().equals(dustForm.getRoad())){ HashMap<String, Object> map = new HashMap<>(); map.put("road",road.getName()); -- Gitblit v1.8.0