From 32cc13189371ee1e367897a64fbc22f90b53add8 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Wed, 19 Jun 2024 16:24:26 +0800
Subject: [PATCH] fix:尘负荷排序接口提交
---
screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java | 78 +++++++++++++++++++++++++++++++++++++++
screen-api/src/main/java/com/moral/api/service/DustldService.java | 4 +
screen-api/src/main/java/com/moral/api/controller/CruiserController.java | 11 +++++
3 files changed, 92 insertions(+), 1 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/controller/CruiserController.java b/screen-api/src/main/java/com/moral/api/controller/CruiserController.java
index 6f71385..fbab51d 100644
--- a/screen-api/src/main/java/com/moral/api/controller/CruiserController.java
+++ b/screen-api/src/main/java/com/moral/api/controller/CruiserController.java
@@ -23,6 +23,7 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@@ -290,6 +291,16 @@
}
+ @GetMapping("sort")
+ @ApiOperation("������������")
+ public ResultMessage sectionRanking(@RequestParam @ApiParam(value = "mac",name = "mac���") String mac,
+ @RequestParam @ApiParam(value = "startTime",name = "������������") String startTime,
+ @RequestParam @ApiParam(value = "endTime",name = "������������") String endTime){
+
+ List<DustForm> sort = dustldService.sort(mac, startTime, endTime);
+ return ResultMessage.ok(sort);
+ }
+
public static void downloadWord(String fileName, Map<String, Object> params, HttpServletResponse response, String newFileName) {
diff --git a/screen-api/src/main/java/com/moral/api/service/DustldService.java b/screen-api/src/main/java/com/moral/api/service/DustldService.java
index c000340..f3b23c7 100644
--- a/screen-api/src/main/java/com/moral/api/service/DustldService.java
+++ b/screen-api/src/main/java/com/moral/api/service/DustldService.java
@@ -7,6 +7,7 @@
import java.util.Map;
import com.moral.api.entity.Dustld;
+import com.moral.api.pojo.dust.DustForm;
public interface DustldService {
@@ -26,6 +27,7 @@
List<Dustld> selectAll(Map<String, Object> params);
-
+ //������������
+ List<DustForm> sort(String mac,String startTime,String endTime);
}
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 0cbe0c8..0d5d1c2 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
@@ -459,6 +459,84 @@
return dustlds;
}
+ /**
+ * ������������
+ * @param mac
+ * @param startTime
+ * @param endTime
+ * @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;
+ }
+
//������������������
private String getList(String path, List<MultipartFile> files1) {
--
Gitblit v1.8.0