From 4107073950f459e051e5b9e828750ab57be3863b Mon Sep 17 00:00:00 2001
From: cjl <276999030@qq.com>
Date: Wed, 15 Nov 2023 16:03:53 +0800
Subject: [PATCH] fix:补充提交
---
screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java | 83 ++++++++++++++++++++---------------------
1 files changed, 40 insertions(+), 43 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 a552f8d..4ce7314 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,10 @@
package com.moral.api.service.impl;
+import com.moral.api.exception.BusinessException;
+import com.moral.api.mapper.*;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Service;
@@ -36,10 +39,6 @@
import com.moral.api.entity.Dustld;
import com.moral.api.entity.ManageCoordinate;
import com.moral.api.entity.MaxRoad;
-import com.moral.api.mapper.DustldMapper;
-import com.moral.api.mapper.HistorySecondCruiserMapper;
-import com.moral.api.mapper.ManageCoordinateMapper;
-import com.moral.api.mapper.MaxRoadMapper;
import com.moral.api.pojo.dto.historySecondCruiser.DustldDTO;
import com.moral.api.pojo.dust.DustForm;
import com.moral.api.pojo.dust.TimeForm;
@@ -90,29 +89,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);
}
@@ -274,14 +269,21 @@
private ManageCoordinateMapper manageCoordinateMapper;
@Autowired
private MaxRoadMapper maxRoadMapper;
+ @Autowired
+ private OrganizationMapper organizationMapper;
@Override
@Transactional
- public Map<String, Object> dailyDustlds(List<MultipartFile> file,Map<String, Object> params) {
+ public Map<String, Object> dailyDustlds(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 mac = params.get("mac").toString();
+ List<Integer> orgList = organizationMapper.orgIdSpecialDevList(orgId,mac);
+ if(CollectionUtils.isEmpty(orgList)){
+ throw new BusinessException("������������������������������������");
+ }
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);
@@ -290,10 +292,13 @@
String rsTime2 = dateString2.substring(5, 14);
HashMap<String, Object> rsMap = new HashMap<>();
List<Map<String, Object>> dusts = historySecondCruiserMapper.getDusts(params);
- Map<String, List<DustldDTO>> collect = manageCoordinateMapper.CompareTo(orgId).stream().collect(Collectors.groupingBy(o -> o.getName()));
+ 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<>();
- ArrayList<DustForm> list2 = new ArrayList<>();
+ //���������������������
StringBuilder builder = new StringBuilder();
int i = 1;
@@ -338,15 +343,14 @@
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);
if (rsAvg>=0.3){
builder.append("("+i+")"+string);
i++;
- list1.add(dustForm);
//������������������
QueryWrapper<MaxRoad> wrapper = new QueryWrapper<>();
wrapper.eq("name",string);
@@ -359,18 +363,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<>();
@@ -384,23 +384,20 @@
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 : maxRoads1) {
- for (DustForm dustForm : dustForms) {
+ for (DustForm dustForm : list1) {
if (road.getName().equals(dustForm.getRoad())){
HashMap<String, Object> map = new HashMap<>();
map.put("road",road.getName());
- map.put("value1",road.getData());
- map.put("value2",dustForm.getValue());
- map.put("value3",road.getData()-dustForm.getValue());
+ map.put("value1",String.format("%.2f",road.getData()));
+ map.put("value2",String.format("%.2f",dustForm.getValue()));
+ map.put("value3",String.format("%.2f",road.getData()-dustForm.getValue()));
list3.add(map);
}
}
}
- rsMap.put("data",builder);
+ rsMap.put("data",ObjectUtils.isEmpty(builder)?"������������������":builder);
rsMap.put("list3",list3);
rsMap.put("time",rsTime1+"-"+rsTime2);
rsMap.put("date1",dateString3.substring(5,10));
--
Gitblit v1.8.0